From ab35a8bd360b647c8da75486be0dd765c1d59b3d Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Thu, 27 Oct 2016 14:59:10 +0200 Subject: [PATCH] #213 add reset option while editing the templates -> for reverting to the latest saved state --- .../js/admin/feature/resources/edit/resources-edit.html | 1 + .../js/admin/feature/resources/edit/resources-edit.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.html b/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.html index e22a9d3584..681a3116b1 100644 --- a/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.html +++ b/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.html @@ -14,6 +14,7 @@

Edit resource: {{$ctrl.resourceName}}

+
diff --git a/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.js b/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.js index 6489a4b0cc..892f91eafa 100644 --- a/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.js +++ b/src/main/webapp/resources/js/admin/feature/resources/edit/resources-edit.js @@ -16,6 +16,7 @@ function ResourcesEditCtrl(ResourceService, EventService) { ctrl.saveFor = saveFor; ctrl.deleteFor = deleteFor; + ctrl.resetFor = resetFor; ctrl.$onInit = function() { loadAll() @@ -31,10 +32,15 @@ function ResourcesEditCtrl(ResourceService, EventService) { ResourceService.deleteFile(ctrl.event.organizationId, ctrl.event.id, getFileName(locale)).then(loadAll); } + function resetFor(locale) { + ctrl.resources[locale] = ctrl.originalResources[locale] || ctrl.templateBodies[locale]; + } + function loadAll() { ctrl.templateBodies = {}; ctrl.resources = {}; ctrl.resourcesMetadata = {}; + ctrl.originalResources = {}; EventService.getSelectedLanguages(ctrl.event.shortName).then(function(lang) { @@ -54,6 +60,7 @@ function ResourcesEditCtrl(ResourceService, EventService) { ctrl.resourcesMetadata[locale] = res.data; ResourceService.getEventResource(ctrl.event.organizationId, ctrl.event.id, getFileName(locale)).then(function(resource) { ctrl.resources[locale] = resource.data; + ctrl.originalResources[locale] = resource.data; }) }, function() { //if there is no file for the given locale, use the template instead