diff --git a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js index 94be12e89..a50182f1b 100644 --- a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js @@ -181,8 +181,6 @@ describe('workerTimeControl add/delete timeEntry()', () => { ctx.args = {direction: 'out'}; const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options); - // const deletedTimeEntry = await models.WorkerTimeControl.findById(createdTimeEntry.id, null, options); - expect(updatedTimeEntry.direction).toEqual('out'); await tx.rollback(); } catch (e) { diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index a973b510e..66d6f282e 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -133,8 +133,8 @@ - - + this.fetchHours()); + try { + const entry = this.newTimeEntry; + if (!entry.direction) + throw new Error(`The entry type can't be empty`); + + const query = `WorkerTimeControls/${this.worker.id}/addTimeEntry`; + this.$http.post(query, entry) + .then(() => this.fetchHours()); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + return false; + } + + return true; } showDeleteDialog($event, hour) { @@ -284,12 +295,19 @@ class Controller extends Section { } save() { - const entry = this.selectedRow; - const query = `WorkerTimeControls/${entry.id}/updateTimeEntry`; - this.$http.post(query, {direction: entry.direction}) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.$.editEntry.hide()) - .then(() => this.fetchHours()); + try { + const entry = this.selectedRow; + if (!entry.direction) + throw new Error(`The entry type can't be empty`); + + const query = `WorkerTimeControls/${entry.id}/updateTimeEntry`; + this.$http.post(query, {direction: entry.direction}) + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) + .then(() => this.$.editEntry.hide()) + .then(() => this.fetchHours()); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + } } } diff --git a/modules/worker/front/time-control/locale/es.yml b/modules/worker/front/time-control/locale/es.yml index 98c317793..8b2486f05 100644 --- a/modules/worker/front/time-control/locale/es.yml +++ b/modules/worker/front/time-control/locale/es.yml @@ -9,4 +9,5 @@ Current week: Semana actual This time entry will be deleted: Se eliminará la hora fichada Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla? Finish at: Termina a las -Entry removed: Fichada borrada \ No newline at end of file +Entry removed: Fichada borrada +The entry type can't be empty: El tipo de fichada no puede quedar vacía \ No newline at end of file diff --git a/modules/worker/front/time-control/style.scss b/modules/worker/front/time-control/style.scss index 2a91a865e..6a46921a7 100644 --- a/modules/worker/front/time-control/style.scss +++ b/modules/worker/front/time-control/style.scss @@ -24,7 +24,8 @@ vn-worker-time-control { .totalBox { max-width: none } - .edit-entry { - width: 150px - } +} + +.edit-time-entry { + width: 200px } \ No newline at end of file