Ammends
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-06-18 12:32:37 +02:00
parent c622f24b0a
commit 0ff114ff36
5 changed files with 35 additions and 17 deletions

View File

@ -181,8 +181,6 @@ describe('workerTimeControl add/delete timeEntry()', () => {
ctx.args = {direction: 'out'}; ctx.args = {direction: 'out'};
const updatedTimeEntry = await models.WorkerTimeControl.updateTimeEntry(ctx, createdTimeEntry.id, options); 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'); expect(updatedTimeEntry.direction).toEqual('out');
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -133,8 +133,8 @@
<!-- Edit entry Popover --> <!-- Edit entry Popover -->
<vn-popover vn-id="editEntry"> <vn-popover vn-id="editEntry">
<vn-horizontal class="vn-pa-sm edit-entry"> <vn-horizontal class="vn-pa-sm edit-time-entry">
<vn-autocomplete class="dense" style="width: 200px" <vn-autocomplete class="dense"
ng-model="$ctrl.selectedRow.direction" ng-model="$ctrl.selectedRow.direction"
data="$ctrl.entryDirections" data="$ctrl.entryDirections"
select-fields="['code','description']" select-fields="['code','description']"

View File

@ -255,9 +255,20 @@ class Controller extends Section {
} }
addTime() { addTime() {
const query = `WorkerTimeControls/${this.worker.id}/addTimeEntry`; try {
this.$http.post(query, this.newTimeEntry) const entry = this.newTimeEntry;
.then(() => this.fetchHours()); 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) { showDeleteDialog($event, hour) {
@ -284,12 +295,19 @@ class Controller extends Section {
} }
save() { save() {
const entry = this.selectedRow; try {
const query = `WorkerTimeControls/${entry.id}/updateTimeEntry`; const entry = this.selectedRow;
this.$http.post(query, {direction: entry.direction}) if (!entry.direction)
.then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) throw new Error(`The entry type can't be empty`);
.then(() => this.$.editEntry.hide())
.then(() => this.fetchHours()); 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));
}
} }
} }

View File

@ -9,4 +9,5 @@ Current week: Semana actual
This time entry will be deleted: Se eliminará la hora fichada This time entry will be deleted: Se eliminará la hora fichada
Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla? Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla?
Finish at: Termina a las Finish at: Termina a las
Entry removed: Fichada borrada Entry removed: Fichada borrada
The entry type can't be empty: El tipo de fichada no puede quedar vacía

View File

@ -24,7 +24,8 @@ vn-worker-time-control {
.totalBox { .totalBox {
max-width: none max-width: none
} }
.edit-entry { }
width: 150px
} .edit-time-entry {
width: 200px
} }