Skip to content

Commit

Permalink
fixed issue #560 + updated the LICENSE (still MIT)
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Feb 1, 2013
1 parent 8312800 commit 2cc34a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
== MIT License

Copyright (c) 2010-2012, Didier Lafforgue.
Copyright (c) 2010-2013, Didier Lafforgue.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Expand Up @@ -11,6 +11,9 @@ class Locomotive.Models.ContentType extends Backbone.Model
@set
entries_custom_fields: new Locomotive.Models.CustomFieldsCollection(@get('entries_custom_fields'))

find_entries_custom_field: (name) ->
@get('entries_custom_fields').find((field) => field.get('name') == name)

toJSON: ->
_.tap super, (hash) =>
_.each ['label_field_id_text', 'group_by_field_id_text', 'public_submission_accounts_text', 'target_klass_name_text', 'content_type_id_text', 'public_submission_account_emails'], (key) => delete hash[key]
Expand Down
Expand Up @@ -22,7 +22,7 @@ class Locomotive.Views.Shared.Fields.SelectView extends Backbone.View
render_for: (name, callback) ->
@name = name; @on_save_callback = callback

@custom_field = @model.get('entries_custom_fields').find((field) => field.get('name') == @name)
@custom_field = @model.find_entries_custom_field(@name)

@render()

Expand Down Expand Up @@ -57,6 +57,10 @@ class Locomotive.Views.Shared.Fields.SelectView extends Backbone.View
on_save: (model, response) =>
$.rails.enableFormElements(@$buttons_pane)
model._normalize()

# the field has been changed as well as its select options, so get a fresh copy.
@custom_field = model.find_entries_custom_field(@custom_field.get('name'))

@$form.trigger('ajax:complete')
@on_save_callback(@custom_field.get('select_options').sortBy((option) -> option.get('position'))) if @on_save_callback?
@close()
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/locomotive/content_entry_presenter.rb
Expand Up @@ -19,7 +19,7 @@ class ContentEntryPresenter < BasePresenter

with_options only_getter: true, if: Proc.new { html_view? } do |presenter|
presenter.properties :safe_attributes
presenter.properties :file_custom_fields, :has_many_custom_fields, :many_to_many_custom_fields
presenter.properties :select_custom_fields, :file_custom_fields, :has_many_custom_fields, :many_to_many_custom_fields
end

## callbacks ##
Expand Down

0 comments on commit 2cc34a3

Please sign in to comment.