From 91af53dce7183146f79313df48f7e58b4d950598 Mon Sep 17 00:00:00 2001
From: cedricnjanga
Date: Tue, 10 Oct 2017 01:23:01 +0200
Subject: Add plugins to webpack config
---
app/javascript/time_tables/actions/index.js | 24 +++++-----
app/javascript/time_tables/components/Navigate.js | 4 +-
.../time_tables/components/PeriodForm.js | 4 +-
.../time_tables/components/SaveTimetable.js | 1 -
.../time_tables/components/TagsSelect2.js | 13 +++---
.../time_tables/containers/PeriodForm.js | 4 +-
app/javascript/time_tables/reducers/metas.js | 19 ++++----
app/javascript/time_tables/reducers/modal.js | 26 +++++------
app/javascript/time_tables/reducers/pagination.js | 12 ++---
app/javascript/time_tables/reducers/status.js | 8 ++--
app/javascript/time_tables/reducers/timetable.js | 51 ++++++++++++----------
11 files changed, 88 insertions(+), 78 deletions(-)
(limited to 'app/javascript/time_tables')
diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js
index 5a02e8523..13cb96b64 100644
--- a/app/javascript/time_tables/actions/index.js
+++ b/app/javascript/time_tables/actions/index.js
@@ -1,10 +1,14 @@
-import _ from 'lodash'
+import range from 'lodash/range'
+import assign from 'lodash/assign'
+import reject from 'lodash/reject'
+import some from 'lodash/some'
+import every from 'lodash/every'
import clone from '../../helpers/clone'
const I18n = clone(window, "I18n")
const actions = {
weekDays: (index) => {
- return _.range(1, 8).map(n => I18n.time_tables.edit.metas.days[n])
+ return range(1, 8).map(n => I18n.time_tables.edit.metas.days[n])
},
strToArrayDayTypes: (str) =>{
return actions.weekDays().map(day => str.indexOf(day) !== -1)
@@ -151,7 +155,7 @@ const actions = {
type : 'CLOSE_MODAL'
}),
monthName(strDate) {
- let monthList = _.range(1,13).map(n => I18n.calendars.months[n])
+ let monthList = range(1,13).map(n => I18n.calendars.months[n])
let date = new Date(strDate)
return monthList[date.getMonth()]
},
@@ -172,12 +176,12 @@ const actions = {
return date.toLocaleDateString()
},
updateSynthesis: ({current_month, time_table_dates: dates, time_table_periods: periods}) => {
- let newPeriods = _.reject(periods, 'deleted')
+ let newPeriods = reject(periods, 'deleted')
let improvedCM = current_month.map((d, i) => {
let isInPeriod = actions.isInPeriod(newPeriods, d.date)
- let isIncluded = _.some(dates, {'date': d.date, 'in_out': true})
+ let isIncluded = some(dates, {'date': d.date, 'in_out': true})
- return _.assign({}, current_month[i], {
+ return assign({}, current_month[i], {
in_periods: isInPeriod,
include_date: isIncluded,
excluded_date: !isInPeriod ? false : current_month[i].excluded_date
@@ -271,8 +275,8 @@ const actions = {
submitTimetable: (dispatch, timetable, metas, next) => {
dispatch(actions.fetchingApi())
let strDayTypes = actions.arrayToStrDayTypes(metas.day_types)
- metas.day_types= strDayTypes
- let sentState = _.assign({}, timetable, metas)
+ metas.day_types = strDayTypes
+ let sentState = assign({}, timetable, metas)
let urlJSON = window.location.pathname.split('/', 5).join('/')
let hasError = false
fetch(urlJSON + '.json', {
@@ -302,8 +306,8 @@ const actions = {
})
},
errorModalKey: (periods, dayTypes) => {
- const withoutPeriodsWithDaysTypes = _.reject(periods, 'deleted').length == 0 && _.some(dayTypes) && "withoutPeriodsWithDaysTypes"
- const withPeriodsWithoutDayTypes = _.reject(periods, 'deleted').length > 0 && _.every(dayTypes, dt => dt == false) && "withPeriodsWithoutDayTypes"
+ const withoutPeriodsWithDaysTypes = reject(periods, 'deleted').length == 0 && some(dayTypes) && "withoutPeriodsWithDaysTypes"
+ const withPeriodsWithoutDayTypes = reject(periods, 'deleted').length > 0 && every(dayTypes, dt => dt == false) && "withPeriodsWithoutDayTypes"
return (withoutPeriodsWithDaysTypes || withPeriodsWithoutDayTypes) && (withoutPeriodsWithDaysTypes ? "withoutPeriodsWithDaysTypes" : "withPeriodsWithoutDayTypes")
diff --git a/app/javascript/time_tables/components/Navigate.js b/app/javascript/time_tables/components/Navigate.js
index 6ae80bce0..7307d819b 100644
--- a/app/javascript/time_tables/components/Navigate.js
+++ b/app/javascript/time_tables/components/Navigate.js
@@ -1,5 +1,5 @@
import React, { PropTypes, Component } from 'react'
-import _ from 'lodash'
+import map from 'lodash/map'
import actions from '../actions'
export default function Navigate({ dispatch, metas, timetable, pagination, status, filters}) {
@@ -30,7 +30,7 @@ export default function Navigate({ dispatch, metas, timetable, pagination, statu
className='dropdown-menu'
aria-labelledby='date_selector'
>
- {_.map(pagination.periode_range, (month, i) => (
+ {map(pagination.periode_range, (month, i) => (