app/views/alchemy/admin/nodes/_form.html.erb in alchemy-custom-model-3.1.1 vs app/views/alchemy/admin/nodes/_form.html.erb in alchemy-custom-model-3.1.2

- old
+ new

@@ -1,77 +1,59 @@ <%= alchemy_form_for([:admin, node]) do |f| %> + <% if node.new_record? && node.root? %> + <%= f.input :menu_type, + collection: Alchemy::Language.current.available_menu_names.map { |n| [I18n.t(n, scope: [:alchemy, :menu_names]), n] }, + include_blank: false, + input_html: { class: 'alchemy_selectbox' } %> - <% if node.root? %> - - <% if Alchemy::Node.respond_to? :available_menu_names %> - <%= f.input :name, - collection: Alchemy::Node.available_menu_names.map { |n| [I18n.t(n, scope: [:alchemy, :menu_names]), n] }, - include_blank: false, - input_html: {class: 'alchemy_selectbox'} %> + <% else %> + <% if node.root? %> + <%= f.input :name %> <% else %> <%= f.input :name, input_html: { - autofocus: true, - value: node.page && node.read_attribute(:name).blank? ? nil : node.name, - placeholder: node.page ? node.page.name : nil - } %> - <% end %> - - <% else %> - - <%= f.input :name, as: :string, input_html: { autofocus: true, value: node.page && node.read_attribute(:name).blank? ? nil : node.name, placeholder: node.page ? node.page.name : nil - } %> - - <% - active_klass = (node.errors.keys.include? :custom_model_klass or + } %> + <% + active_klass = (node.errors.keys.include? :custom_model_klass or node.custom_model?) ? "ui-tabs-active" : "" - %> + %> - <div class="container_selctor_age_custom_model"> - <div id="tabs_nodes" class="ui-tabs ui-corner-all ui-widget ui-widget-content"> - <ul role="tablist" class="ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header"> - <li role="tab" tabindex="0" class="ui-tabs-tab ui-corner-top ui-state-default ui-tab"> - <a href="#pages" role="presentation" tabindex="-1" class="ui-tabs-anchor" id="ui-id-1"> - <%= Alchemy.t(:pages_select) %> - </a> - </li> - <li role="tab" tabindex="1" class="ui-tabs-tab ui-corner-top ui-tab <%= active_klass %>"> - <a href="#custom_models" role="presentation" tabindex="1" class="ui-tabs-anchor" id="ui-id-2"> - <%= Alchemy.t(:custom_models) %> - </a> - </li> - </ul> - <div id="custom_models" aria-labelledby="legacy_urls_label" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="false"> - <%= f.input :custom_model_klass, input_html: {class: 'alchemy_selectbox'} %> - <%= f.input :custom_model_method, input_html: {class: 'alchemy_selectbox'} %> - </div> - <div id="pages" aria-labelledby="ui-id-1" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="false"> - <%= f.input :page_id, label: Alchemy::Page.model_name.human, input_html: {class: 'alchemy_selectbox'} %> - <%= f.input :url, input_html: {disabled: node.page}, hint: Alchemy.t(:node_url_hint) %> - <%= f.input :title %> - <%= f.input :nofollow %> - <%= f.input :external %> - <%= f.hidden_field :parent_id %> - </div> + <div class="container_selctor_age_custom_model"> + <div id="tabs_nodes" class="ui-tabs ui-corner-all ui-widget ui-widget-content"> + <ul role="tablist" class="ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header"> + <li role="tab" tabindex="0" class="ui-tabs-tab ui-corner-top ui-state-default ui-tab"> + <a href="#pages" role="presentation" tabindex="-1" class="ui-tabs-anchor" id="ui-id-1"> + <%= Alchemy.t(:pages_select) %> + </a> + </li> + <li role="tab" tabindex="1" class="ui-tabs-tab ui-corner-top ui-tab <%= active_klass %>"> + <a href="#custom_models" role="presentation" tabindex="1" class="ui-tabs-anchor" id="ui-id-2"> + <%= Alchemy.t(:custom_models) %> + </a> + </li> + </ul> + <div id="custom_models" aria-labelledby="legacy_urls_label" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="false"> + <%= f.input :custom_model_klass, input_html: {class: 'alchemy_selectbox'} %> + <%= f.input :custom_model_method, input_html: {class: 'alchemy_selectbox'} %> + </div> + <div id="pages" aria-labelledby="ui-id-1" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="false"> + <%= f.input :page_id, label: Alchemy::Page.model_name.human, input_html: {class: 'alchemy_selectbox'} %> + <%= f.input :url, input_html: {disabled: node.page}, hint: Alchemy.t(:node_url_hint) %> + <%= f.input :title %> + <%= f.input :nofollow %> + <%= f.input :external %> + <%= f.hidden_field :parent_id %> + </div> + </div> </div> - </div> - - - - - + <% end %> <% end %> - <% if node.respond_to? :site_id %> - <%= f.hidden_field :site_id %> - <% end %> - <% if node.respond_to? :language_id %> - <%= f.hidden_field :language_id %> - <% end %> + <%= f.hidden_field :language_id %> <%= f.submit button_label %> <% end %> <script> @@ -100,27 +82,26 @@ } } }) - $('#node_custom_model_method').select2('disable'); $('#node_page_id').alchemyPageSelect({ placeholder: "<%= Alchemy.t(:search_page) %>", url: "<%= alchemy.api_pages_path %>", <% if node.page %> initialSelection: { id: <%= node.page_id %>, text: "<%= node.page.name %>", - url: "/<%= node.page.urlname %>" + url_path: "<%= node.page.url_path %>" } <% end %> - }).on('change', function (e) { + }).on('change', function(e) { if (e.val === '') { $('#node_name').removeAttr('placeholder') $('#node_url').val('').prop('disabled', false) } else { $('#node_name').attr('placeholder', e.added.name) - $('#node_url').val('/' + e.added.urlname).prop('disabled', true) + $('#node_url').val(e.added.url_path).prop('disabled', true) } }) </script>