diff --git a/zmsadmin/js/block/scope/emergencyend.js b/zmsadmin/js/block/scope/emergencyend.js new file mode 100644 index 000000000..0667cd603 --- /dev/null +++ b/zmsadmin/js/block/scope/emergencyend.js @@ -0,0 +1,40 @@ +import $ from 'jquery' + +class EndEmergencyView { + + constructor(element, options) { + this.includeUrl = options.includeurl + this.scope = options.scope + this.workstationName = "" + options.workstationname + this.data = {} + this.$ = $(element) + + this.$.find('.emergency__button-end').on('click', this.endEmergency.bind(this)) + } + + endEmergency() { + this.update({ activated: "0", calledByWorkstation: "-1", acceptedByWorkstation: "-1" }) + this.sendEmergencyCancel() + } + + update(newData) { + this.data = Object.assign({}, this.data, newData) + } + + sendEmergencyCancel() { + const url = `${this.includeUrl}/scope/${this.scope.id}/emergency/` + + return new Promise((resolve, reject) => { + $.ajax(url, { + method: 'GET' + }).done(() => { + resolve() + }).fail(err => { + console.log('XHR error', url, err) + reject(err) + }) + }) + } +} + +export default EndEmergencyView; \ No newline at end of file diff --git a/zmsadmin/js/index.js b/zmsadmin/js/index.js index 6b1ec817f..2a85edea2 100644 --- a/zmsadmin/js/index.js +++ b/zmsadmin/js/index.js @@ -26,6 +26,7 @@ import PickupKeyboardHandheldView from "./page/pickup/keyboard-handheld" import StatisticView from './page/statistic' import LoginScopeSelectView from './block/scope/loginselectform' +import EmergencyEnd from './block/scope/emergencyend' //import AvailabilityDayPage from './page/availabilityDay' import WeekCalendarPage from './page/weekCalendar' import printScopeAppointmentsByDay from './page/scopeAppointmentsByDay/print' @@ -108,6 +109,10 @@ $('[data-scope-select-form]').each(function () { new LoginScopeSelectView(this, getDataAttributes(this)); }) +$('.emergency-end').each(function () { + new EmergencyEnd(this, getDataAttributes(this)); +}) + $('.pickup-view').each(function () { new PickupView(this, getDataAttributes(this)); }) diff --git a/zmsadmin/templates/block/scope/form.twig b/zmsadmin/templates/block/scope/form.twig index 568b5dcf8..6f9c4d439 100644 --- a/zmsadmin/templates/block/scope/form.twig +++ b/zmsadmin/templates/block/scope/form.twig @@ -627,7 +627,12 @@