From c5d6252c7ae66db9f4c640635153a3f5bcd44b60 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Tue, 24 Mar 2015 17:35:43 +0100 Subject: [PATCH] Fix destroy problem and add section area explanation --- .../modals/base_controller.js.coffee | 4 ++-- .../controllers/schedule_controller.js.coffee | 2 +- .../controllers/section_controller.js.coffee | 6 ++++++ .../templates/modals/employee_shift.emblem | 2 +- .../modals/product_category_edit.emblem | 2 +- .../app/templates/modals/section_area.emblem | 3 ++- .../supplier/foundation1/application.js.erb | 1 - .../javascripts/translations.js.coffee.erb | 1 - app/views/admin/svg_elements/index.html.slim | 5 ++++- app/views/admin/svg_elements/show.html.slim | 20 ++++++++----------- config/locales/models.en.yml | 1 + config/locales/models.nl.yml | 1 + config/locales/supplier.en.yml | 3 +++ config/locales/supplier.nl.yml | 3 +++ 14 files changed, 33 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee index 6ed36a03..c722c533 100644 --- a/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee @@ -59,9 +59,9 @@ if @get('model.isValid') @get('model').save().then @save_success.bind(@), @save_error.bind(@) #@send 'closeModal' unless @preventClose - destroy: -> + destroyRecord: -> my_scope = @ - destroy_callback = @get('modal_options.destroy') + destroy_callback = @get('modal_options.destroy_callback') @modal 'confirm', title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text' model: @get('model') diff --git a/app/assets/javascripts/supplier/app/controllers/schedule_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/schedule_controller.js.coffee index 9fc70c9d..c0936f50 100644 --- a/app/assets/javascripts/supplier/app/controllers/schedule_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/schedule_controller.js.coffee @@ -11,4 +11,4 @@ App.ScheduleController = Ember.ArrayController.extend destroy_text_path: 'employee_shift.modal.destroy_confirmation' model: employee_shift save: -> callbacks.save.call(@, employee_shift) if callbacks.save - destroy: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy + destroy_callback: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy diff --git a/app/assets/javascripts/supplier/app/controllers/section_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/section_controller.js.coffee index 5376e4c3..c1b8d4c3 100644 --- a/app/assets/javascripts/supplier/app/controllers/section_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/section_controller.js.coffee @@ -37,10 +37,16 @@ App.SectionController = Ember.ObjectController.extend addSectionArea: -> section_area = @store.createRecord('section-area') section_area.set 'section', @get('model') + @set 'editmode', true @modal 'section_area', title_path: 'section_area.add_button' model: section_area ok: => @send 'makeEditable' + close: => + if section_area.get('isNew') + section_area.deleteRecord() + else + section_area.rollback() removeSectionElement: (section_element)-> section_element.destroyRecord() textures: ['wood1', 'wood2'] diff --git a/app/assets/javascripts/supplier/app/templates/modals/employee_shift.emblem b/app/assets/javascripts/supplier/app/templates/modals/employee_shift.emblem index 26397882..6b867520 100644 --- a/app/assets/javascripts/supplier/app/templates/modals/employee_shift.emblem +++ b/app/assets/javascripts/supplier/app/templates/modals/employee_shift.emblem @@ -11,5 +11,5 @@ hr button.modal-close{action "close"}=t 'employee_shift.modal.close_button' button.modal-confirm.right{action "save"} disabled=model.isInvalid =t 'employee_shift.modal.save_button' -button.modal-destroy.right{action "destroy"} +button.modal-destroy.right{action "destroyRecord"} =t 'employee_shift.modal.destroy_button' diff --git a/app/assets/javascripts/supplier/app/templates/modals/product_category_edit.emblem b/app/assets/javascripts/supplier/app/templates/modals/product_category_edit.emblem index 6eff1df7..de69560f 100644 --- a/app/assets/javascripts/supplier/app/templates/modals/product_category_edit.emblem +++ b/app/assets/javascripts/supplier/app/templates/modals/product_category_edit.emblem @@ -3,4 +3,4 @@ p=t 'product_category.modal.edit.body_header' hr button.modal-close{action "close"}=t 'product_category.modal.edit.close_button' button.modal-save.right{action "save"}=t 'product_category.modal.edit.save_button' -button.modal-destroy.right{action "destroy"}=t 'product_category.modal.edit.destroy_button' +button.modal-destroy.right{action "destroyRecord"}=t 'product_category.modal.edit.destroy_button' diff --git a/app/assets/javascripts/supplier/app/templates/modals/section_area.emblem b/app/assets/javascripts/supplier/app/templates/modals/section_area.emblem index 3e468d81..fd2bdae3 100644 --- a/app/assets/javascripts/supplier/app/templates/modals/section_area.emblem +++ b/app/assets/javascripts/supplier/app/templates/modals/section_area.emblem @@ -1,3 +1,4 @@ +p= t 'section_area.modal.explanation' .form-row.title .form-label=t 'attributes.section_area.title' .form-field @@ -18,4 +19,4 @@ hr button.modal-close{action "close"}=t 'section_area.modal.close_button' button.modal-confirm.right{action "save"} disabled=model.isInvalid =t 'section_area.modal.save_button' -button.modal-destroy.right{action "destroy"}= t 'section_area.modal.destroy_button' +button.modal-destroy.right{action "destroyRecord"}= t 'section_area.modal.destroy_button' diff --git a/app/assets/javascripts/supplier/foundation1/application.js.erb b/app/assets/javascripts/supplier/foundation1/application.js.erb index 714541c0..ce0ba41a 100644 --- a/app/assets/javascripts/supplier/foundation1/application.js.erb +++ b/app/assets/javascripts/supplier/foundation1/application.js.erb @@ -23,7 +23,6 @@ $.extend($translations.en, <%= I18n.t('supplier', locale: :en).to_json %>); $.extend($translations.nl, <%= I18n.t('supplier', locale: :nl).to_json %>); String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } - window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>; window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>; diff --git a/app/assets/javascripts/translations.js.coffee.erb b/app/assets/javascripts/translations.js.coffee.erb index 5b2a3f9c..2e668c6f 100644 --- a/app/assets/javascripts/translations.js.coffee.erb +++ b/app/assets/javascripts/translations.js.coffee.erb @@ -18,7 +18,6 @@ return "" unless minutes [("0" + Math.floor(minutes/60)).substr(-2,2), ("0" + Math.floor(minutes%60)).substr(-2,2)].join(":") - @ttry = (path, vars={})-> @t(path, $.extend(vars, emptyWhenNotFound: true)) diff --git a/app/views/admin/svg_elements/index.html.slim b/app/views/admin/svg_elements/index.html.slim index 312f116d..a1b0cd0b 100644 --- a/app/views/admin/svg_elements/index.html.slim +++ b/app/views/admin/svg_elements/index.html.slim @@ -16,4 +16,7 @@ = link_to t("helpers.links.destroy"), [:admin, svg_element], method: :delete, data: {confirm: are_you_sure? }, class: 'table-destroy-button' - else = no_content_given model_class -= link_to t("helpers.links.new"), new_admin_svg_element_path, class: 'record-new-button' +/= link_to t("helpers.links.new"), new_admin_svg_element_path, class: 'record-new-button' +- content_for :page_links do + ul + li= link_to link_to_new_content(SvgElement), main_app.new_admin_svg_element_path, class: 'record-new-button' diff --git a/app/views/admin/svg_elements/show.html.slim b/app/views/admin/svg_elements/show.html.slim index c3e2065e..9fb0425e 100644 --- a/app/views/admin/svg_elements/show.html.slim +++ b/app/views/admin/svg_elements/show.html.slim @@ -1,16 +1,12 @@ - model_class = SvgElement -.page-header= title :show, @svg_element +- title :show, @svg_element dl.dl-horizontal.show-list - dt= model_class.human_attribute_name(:number) - dd= @svg_element.number - - if @svg_element.supplier.present? - dt= Supplier.model_name.human - dd= link_to @svg_element.supplier.name, [:admin, @svg_element.supplier] + dt= model_class.human_attribute_name(:name) + dd= @svg_element.name -.form-actions - = link_to t("helpers.links.back"), admin_svg_elements_path, class: 'btn' - ' - = link_to t('helpers.links.edit'), [:edit, :admin, @svg_element], class: 'btn' - ' - = link_to t("helpers.links.destroy"), [:admin, @svg_element], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' +- content_for :page_links do + ul + li=link_to link_to_index_content(SvgElement), main_app.admin_svg_elements_path, class: 'to-index-button' + li=link_to link_to_edit_content(@svg_element), main_app.edit_admin_svg_element_path(@svg_element), class: 'record-edit-button' + li= link_to link_to_destroy_content(@svg_element), [:admin, @svg_element], method: :delete, data: {confirm: are_you_sure?}, class: 'record-destroy-button' diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml index 9f5f9d2a..f4ebee7a 100644 --- a/config/locales/models.en.yml +++ b/config/locales/models.en.yml @@ -124,3 +124,4 @@ en: title: Title width: Width height: Height + rounded: Rounded? diff --git a/config/locales/models.nl.yml b/config/locales/models.nl.yml index 20322a5f..3ecc1efc 100644 --- a/config/locales/models.nl.yml +++ b/config/locales/models.nl.yml @@ -123,3 +123,4 @@ nl: title: Titel width: Breedte height: Hoogte + rounded: Rond? diff --git a/config/locales/supplier.en.yml b/config/locales/supplier.en.yml index 2c19cf2f..ff2c72a7 100644 --- a/config/locales/supplier.en.yml +++ b/config/locales/supplier.en.yml @@ -227,6 +227,9 @@ en: add_button: Add ${models.section_area} modal: title: Add ${models.section_area} + explanation: | + A ${models.section_area} is a block in your ${models.section} to indicate elements to easily recognize your space. + This can be a Bar or special area. save_button: Save close_button: Close destroy_button: Delete diff --git a/config/locales/supplier.nl.yml b/config/locales/supplier.nl.yml index 796d1966..76211d60 100644 --- a/config/locales/supplier.nl.yml +++ b/config/locales/supplier.nl.yml @@ -230,6 +230,9 @@ nl: add_button: ${models.section_area} toevoegen modal: title: ${models.section_area} toevoegen + explanation: | + A ${models.section_area} is a block in your ${models.section} to indicate elements to easily recognize your space. + This can be a Bar or special area. save_button: Save close_button: Close destroy_button: Verwijderen