|
17 | 17 | <!-- <v-menu :value="props.item.date" :close-on-content-click="true" :nudge-right="40" lazy transition="scale-transition" offset-y full-width min-width="290px"> -->
|
18 | 18 | <v-menu :close-on-content-click="true" :nudge-right="40" lazy transition="scale-transition" offset-y full-width min-width="290px" @keyup.esc="model = false">
|
19 | 19 | <v-text-field slot="activator" :value="formatDate(props.item.date)" readonly />
|
20 |
| - <v-date-picker first-day-of-week="1" :value="props.item.date" @input="onUpdateDate({_id: props.item._id, date: $event})" /> |
| 20 | + <v-date-picker first-day-of-week="1" :value="props.item.date" @input="onUpdateDate({id: props.item.id, date: $event})" /> |
21 | 21 | </v-menu>
|
22 | 22 | <!-- {{ formatDate(props.item.date) }} -->
|
23 | 23 | </td>
|
|
26 | 26 | {{ props.item.hours }}
|
27 | 27 | <v-text-field slot="input" :value="props.item.hours" label="Hours" single-line
|
28 | 28 | type="number" min="0" max="20" step="0.5" maxlength="2"
|
29 |
| - @change="onUpdateHours({_id: props.item._id, hours: $event})" |
| 29 | + @change="onUpdateHours({id: props.item.id, hours: $event})" |
30 | 30 | />
|
31 | 31 | </v-edit-dialog>
|
32 | 32 | <!-- {{ props.item.hours }} -->
|
|
36 | 36 | {{ props.item.project }}
|
37 | 37 | <v-select slot="input" :value="props.item.project" item-text="name" item-value="name"
|
38 | 38 | :items="assignedProjects" label="Project" :dense="true" :hide-selected="true"
|
39 |
| - @change="onUpdateProject({_id: props.item._id, project: $event})" |
| 39 | + @change="onUpdateProject({id: props.item.id, project: $event})" |
40 | 40 | />
|
41 | 41 | </v-edit-dialog>
|
42 | 42 | <!-- {{ props.item.project }} -->
|
|
45 | 45 | <v-edit-dialog :return-value="props.item.description" lazy>
|
46 | 46 | {{ props.item.description }}
|
47 | 47 | <v-text-field slot="input" :value="props.item.description" :rules="[ruleMax100chars]" label="Description" single-line
|
48 |
| - counter @change="onUpdateDescription({_id: props.item._id, description: $event})" |
| 48 | + counter @change="onUpdateDescription({id: props.item.id, description: $event})" |
49 | 49 | />
|
50 | 50 | </v-edit-dialog>
|
51 | 51 | <!-- {{ props.item.description }} -->
|
|
55 | 55 | {{ props.item.rate }}
|
56 | 56 | <v-select slot="input" :value="props.item.rate" item-text="name" item-value="name"
|
57 | 57 | :items="rates" label="Rate" :dense="true" :hide-selected="true"
|
58 |
| - @change="onUpdateRate({_id: props.item._id, rate: $event})" |
| 58 | + @change="onUpdateRate({id: props.item.id, rate: $event})" |
59 | 59 | />
|
60 | 60 | </v-edit-dialog>
|
61 | 61 | <!-- {{ props.item.rate }} -->
|
|
80 | 80 |
|
81 | 81 | <script>
|
82 | 82 | import { mapState } from 'vuex'
|
| 83 | + import moment from 'moment-timezone' |
83 | 84 |
|
84 | 85 | export default {
|
85 | 86 | data: () => ({
|
|
146 | 147 | methods: {
|
147 | 148 | onUpdateProject (newValue) {
|
148 | 149 | let payload = {
|
149 |
| - id: newValue._id, |
| 150 | + id: newValue.id, |
150 | 151 | type: 'project',
|
151 | 152 | value: newValue.project
|
152 | 153 | }
|
153 | 154 | this.$store.dispatch('reportedHours/updateAttributeValue', payload)
|
154 | 155 | },
|
155 | 156 | onUpdateDate (newValue) {
|
156 | 157 | let payload = {
|
157 |
| - id: newValue._id, |
| 158 | + id: newValue.id, |
158 | 159 | type: 'date',
|
159 | 160 | value: newValue.date
|
160 | 161 | }
|
161 | 162 | this.$store.dispatch('reportedHours/updateAttributeValue', payload)
|
162 | 163 | },
|
163 | 164 | onUpdateHours (newValue) {
|
164 | 165 | let payload = {
|
165 |
| - id: newValue._id, |
| 166 | + id: newValue.id, |
166 | 167 | type: 'hours',
|
167 | 168 | value: newValue.hours
|
168 | 169 | }
|
169 | 170 | this.$store.dispatch('reportedHours/updateAttributeValue', payload)
|
170 | 171 | },
|
171 | 172 | onUpdateDescription (newValue) {
|
172 | 173 | let payload = {
|
173 |
| - id: newValue._id, |
| 174 | + id: newValue.id, |
174 | 175 | type: 'description',
|
175 | 176 | value: newValue.description
|
176 | 177 | }
|
177 | 178 | this.$store.dispatch('reportedHours/updateAttributeValue', payload)
|
178 | 179 | },
|
179 | 180 | onUpdateRate (newValue) {
|
180 | 181 | let payload = {
|
181 |
| - id: newValue._id, |
| 182 | + id: newValue.id, |
182 | 183 | type: 'rate',
|
183 | 184 | value: newValue.rate
|
184 | 185 | }
|
|
195 | 196 | },
|
196 | 197 | addItem (item) {
|
197 | 198 | let newRecord = {}
|
198 |
| - newRecord._id = null |
| 199 | + newRecord.id = null |
199 | 200 | newRecord.consultant = this.selectedConsultants
|
200 | 201 | console.log('from:', this.dateFrom) /* eslint-disable-line no-console */
|
201 |
| - newRecord.date = this.dateFrom.format('YYYY-MM-DD') |
| 202 | + newRecord.date = this.dateFrom.format('YYYY-MM-DDTHH:mm:ssZ') |
202 | 203 | console.log('date to ISO:', newRecord.date) /* eslint-disable-line no-console */
|
203 | 204 | newRecord.hours = 8
|
204 | 205 | newRecord.rate = 'Off-site'
|
| 206 | + newRecord.project = '' |
205 | 207 | this.$store.dispatch('reportedHours/addRecord', newRecord)
|
206 | 208 | },
|
207 | 209 | duplicateItem (item) {
|
208 | 210 | let newRecord = Object.assign({}, item)
|
209 |
| - // let index = this.selectedReportedHours.indexOf(item) |
210 |
| - newRecord._id = null |
| 211 | + newRecord.id = null |
| 212 | + newRecord.date = moment(item.date).format('YYYY-MM-DDTHH:mm:ssZ') |
211 | 213 | console.log(newRecord) /* eslint-disable-line no-console */
|
212 | 214 | this.$store.dispatch('reportedHours/addRecord', newRecord)
|
213 | 215 | },
|
214 | 216 | deleteItem (item) {
|
215 |
| - confirm('Are you sure you want to delete the record?') && this.$store.dispatch('reportedHours/removeRecord', item._id) |
| 217 | + confirm('Are you sure you want to delete the record?') && this.$store.dispatch('reportedHours/removeRecord', parseInt(item.id, 10)) |
216 | 218 | this.$store.dispatch('context/setNotification', { text: this.formatDate(item.date) + ', ' + item.hours + ' hrs - record deleted', type: 'success' })
|
217 | 219 | }
|
218 | 220 | }
|
|
0 commit comments