Fix destroy problem and add section area explanation

This commit is contained in:
2015-03-24 17:35:43 +01:00
parent 7fb2a0f08c
commit c5d6252c7a
14 changed files with 33 additions and 21 deletions
@@ -59,9 +59,9 @@
if @get('model.isValid') if @get('model.isValid')
@get('model').save().then @save_success.bind(@), @save_error.bind(@) @get('model').save().then @save_success.bind(@), @save_error.bind(@)
#@send 'closeModal' unless @preventClose #@send 'closeModal' unless @preventClose
destroy: -> destroyRecord: ->
my_scope = @ my_scope = @
destroy_callback = @get('modal_options.destroy') destroy_callback = @get('modal_options.destroy_callback')
@modal 'confirm', @modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text' title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
model: @get('model') model: @get('model')
@@ -11,4 +11,4 @@ App.ScheduleController = Ember.ArrayController.extend
destroy_text_path: 'employee_shift.modal.destroy_confirmation' destroy_text_path: 'employee_shift.modal.destroy_confirmation'
model: employee_shift model: employee_shift
save: -> callbacks.save.call(@, employee_shift) if callbacks.save 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
@@ -37,10 +37,16 @@ App.SectionController = Ember.ObjectController.extend
addSectionArea: -> addSectionArea: ->
section_area = @store.createRecord('section-area') section_area = @store.createRecord('section-area')
section_area.set 'section', @get('model') section_area.set 'section', @get('model')
@set 'editmode', true
@modal 'section_area', @modal 'section_area',
title_path: 'section_area.add_button' title_path: 'section_area.add_button'
model: section_area model: section_area
ok: => @send 'makeEditable' ok: => @send 'makeEditable'
close: =>
if section_area.get('isNew')
section_area.deleteRecord()
else
section_area.rollback()
removeSectionElement: (section_element)-> section_element.destroyRecord() removeSectionElement: (section_element)-> section_element.destroyRecord()
textures: ['wood1', 'wood2'] textures: ['wood1', 'wood2']
@@ -11,5 +11,5 @@ hr
button.modal-close{action "close"}=t 'employee_shift.modal.close_button' button.modal-close{action "close"}=t 'employee_shift.modal.close_button'
button.modal-confirm.right{action "save"} disabled=model.isInvalid button.modal-confirm.right{action "save"} disabled=model.isInvalid
=t 'employee_shift.modal.save_button' =t 'employee_shift.modal.save_button'
button.modal-destroy.right{action "destroy"} button.modal-destroy.right{action "destroyRecord"}
=t 'employee_shift.modal.destroy_button' =t 'employee_shift.modal.destroy_button'
@@ -3,4 +3,4 @@ p=t 'product_category.modal.edit.body_header'
hr hr
button.modal-close{action "close"}=t 'product_category.modal.edit.close_button' 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-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'
@@ -1,3 +1,4 @@
p= t 'section_area.modal.explanation'
.form-row.title .form-row.title
.form-label=t 'attributes.section_area.title' .form-label=t 'attributes.section_area.title'
.form-field .form-field
@@ -18,4 +19,4 @@ hr
button.modal-close{action "close"}=t 'section_area.modal.close_button' button.modal-close{action "close"}=t 'section_area.modal.close_button'
button.modal-confirm.right{action "save"} disabled=model.isInvalid button.modal-confirm.right{action "save"} disabled=model.isInvalid
=t 'section_area.modal.save_button' =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'
@@ -23,7 +23,6 @@ $.extend($translations.en, <%= I18n.t('supplier', locale: :en).to_json %>);
$.extend($translations.nl, <%= I18n.t('supplier', locale: :nl).to_json %>); $.extend($translations.nl, <%= I18n.t('supplier', locale: :nl).to_json %>);
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } 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.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 %>; window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
@@ -18,7 +18,6 @@
return "" unless minutes return "" unless minutes
[("0" + Math.floor(minutes/60)).substr(-2,2), ("0" + Math.floor(minutes%60)).substr(-2,2)].join(":") [("0" + Math.floor(minutes/60)).substr(-2,2), ("0" + Math.floor(minutes%60)).substr(-2,2)].join(":")
@ttry = (path, vars={})-> @ttry = (path, vars={})->
@t(path, $.extend(vars, emptyWhenNotFound: true)) @t(path, $.extend(vars, emptyWhenNotFound: true))
+4 -1
View File
@@ -16,4 +16,7 @@
= link_to t("helpers.links.destroy"), [:admin, svg_element], method: :delete, data: {confirm: are_you_sure? }, class: 'table-destroy-button' = link_to t("helpers.links.destroy"), [:admin, svg_element], method: :delete, data: {confirm: are_you_sure? }, class: 'table-destroy-button'
- else - else
= no_content_given model_class = 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'
+8 -12
View File
@@ -1,16 +1,12 @@
- model_class = SvgElement - model_class = SvgElement
.page-header= title :show, @svg_element - title :show, @svg_element
dl.dl-horizontal.show-list dl.dl-horizontal.show-list
dt= model_class.human_attribute_name(:number) dt= model_class.human_attribute_name(:name)
dd= @svg_element.number dd= @svg_element.name
- if @svg_element.supplier.present?
dt= Supplier.model_name.human
dd= link_to @svg_element.supplier.name, [:admin, @svg_element.supplier]
.form-actions - content_for :page_links do
= link_to t("helpers.links.back"), admin_svg_elements_path, class: 'btn' ul
' li=link_to link_to_index_content(SvgElement), main_app.admin_svg_elements_path, class: 'to-index-button'
= link_to t('helpers.links.edit'), [:edit, :admin, @svg_element], class: 'btn' 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'
= link_to t("helpers.links.destroy"), [:admin, @svg_element], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger'
+1
View File
@@ -124,3 +124,4 @@ en:
title: Title title: Title
width: Width width: Width
height: Height height: Height
rounded: Rounded?
+1
View File
@@ -123,3 +123,4 @@ nl:
title: Titel title: Titel
width: Breedte width: Breedte
height: Hoogte height: Hoogte
rounded: Rond?
+3
View File
@@ -227,6 +227,9 @@ en:
add_button: Add ${models.section_area} add_button: Add ${models.section_area}
modal: modal:
title: Add ${models.section_area} 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 save_button: Save
close_button: Close close_button: Close
destroy_button: Delete destroy_button: Delete
+3
View File
@@ -230,6 +230,9 @@ nl:
add_button: ${models.section_area} toevoegen add_button: ${models.section_area} toevoegen
modal: modal:
title: ${models.section_area} toevoegen 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 save_button: Save
close_button: Close close_button: Close
destroy_button: Verwijderen destroy_button: Verwijderen