From 6e94850522deee16d6a3daab5dd77c7da9b10590 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 27 Sep 2016 11:31:20 +0200 Subject: [PATCH] prevent project step reordering to trigger unsaved-changes dialog --- .../javascripts/controllers/projects.coffee.erb | 5 ++++- app/assets/templates/projects/_form.html.erb | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/controllers/projects.coffee.erb b/app/assets/javascripts/controllers/projects.coffee.erb index 27f3307f1..a30a96d9a 100644 --- a/app/assets/javascripts/controllers/projects.coffee.erb +++ b/app/assets/javascripts/controllers/projects.coffee.erb @@ -155,15 +155,18 @@ class ProjectsController ## # Change the step_nb property of the given step to the new value provided. The step that was previously at this # index will be assigned to the old position of the provided step. + # @param event {Object} see https://docs.angularjs.org/guide/expression#-event- # @param step {Object} the project's step to reindex # @param newIdx {number} the new index to assign to the step ## - $scope.changeStepIndex = (step, newIdx) -> + $scope.changeStepIndex = (event, step, newIdx) -> + event.preventDefault() if event for s in $scope.project.project_steps_attributes if s.step_nb == newIdx s.step_nb = step.step_nb step.step_nb = newIdx break + false $scope.autoCompleteName = (nameLookup) -> diff --git a/app/assets/templates/projects/_form.html.erb b/app/assets/templates/projects/_form.html.erb index 005127a29..e660e0501 100644 --- a/app/assets/templates/projects/_form.html.erb +++ b/app/assets/templates/projects/_form.html.erb @@ -79,13 +79,13 @@ {{ 'step_N' | translate:{ INDEX:step.step_nb } }}/{{totalSteps}} - +
- {{ 'add_a_picture' }}{{ 'change_the_picture' }} + {{ 'add_a_picture' | translate }} {{ 'change_the_picture' }} {{step.project_step_image}} @@ -105,11 +105,13 @@
- {{ 'delete_the_step' | translate }} + {{ 'delete_the_step' | translate }}
- {{ 'add_a_new_step' }} + + + {{ 'add_a_new_step' }}