diff --git a/app/assets/images/module/default_widgets/style01.png b/app/assets/images/module/default_widgets/style01.png old mode 100755 new mode 100644 index ff8c4cd6e..2d2aa1997 Binary files a/app/assets/images/module/default_widgets/style01.png and b/app/assets/images/module/default_widgets/style01.png differ diff --git a/app/assets/images/module/default_widgets/style02.png b/app/assets/images/module/default_widgets/style02.png old mode 100755 new mode 100644 index 1eb8f85a3..938b77933 Binary files a/app/assets/images/module/default_widgets/style02.png and b/app/assets/images/module/default_widgets/style02.png differ diff --git a/app/assets/images/module/default_widgets/style03.png b/app/assets/images/module/default_widgets/style03.png old mode 100755 new mode 100644 index 5620f2bac..d3eb1ae94 Binary files a/app/assets/images/module/default_widgets/style03.png and b/app/assets/images/module/default_widgets/style03.png differ diff --git a/app/assets/images/module/default_widgets/style04.png b/app/assets/images/module/default_widgets/style04.png old mode 100755 new mode 100644 index 1ea44651f..8a8948588 Binary files a/app/assets/images/module/default_widgets/style04.png and b/app/assets/images/module/default_widgets/style04.png differ diff --git a/app/assets/images/module/default_widgets/style05.png b/app/assets/images/module/default_widgets/style05.png old mode 100755 new mode 100644 index bcb38f252..a33f8bf61 Binary files a/app/assets/images/module/default_widgets/style05.png and b/app/assets/images/module/default_widgets/style05.png differ diff --git a/app/assets/javascripts/lib/items/items.js.erb b/app/assets/javascripts/lib/items/items.js.erb index 4dbb26e3b..b08b88dda 100644 --- a/app/assets/javascripts/lib/items/items.js.erb +++ b/app/assets/javascripts/lib/items/items.js.erb @@ -189,7 +189,7 @@ function pageSetting(id, edit) { }); $pageCategoryGroup.show(); } - if(val.category.length > 0) { + if(val.tag.length > 0) { $.each(val.tags, function(index, val) { var _arr = $.inArray($(this)[1], _selectData.module.tags[1]); $pageTags.append(''); @@ -385,6 +385,7 @@ $(function() { $pageDivCount.show(); if(event.target.id == 'page_module_app_id') { + $pageCategory.empty(); if(val.category.length > 0) { $.each(val.category, function(index, val) { if(val !== 0) { @@ -398,9 +399,9 @@ $(function() { }); $pageCategoryGroup.show(); } else { - $pageCategory.empty(); $pageCategoryGroup.hide(); } + $pageTags.empty(); if(val.tags.length > 0) { $.each(val.tags, function(index, val) { if(val !== 0) { @@ -414,7 +415,6 @@ $(function() { }); $pageTagsGroup.show(); } else { - $pageTags.empty(); $pageTagsGroup.hide(); } } diff --git a/app/assets/javascripts/lib/items/page_part.js.erb b/app/assets/javascripts/lib/items/page_part.js.erb new file mode 100644 index 000000000..f4b107c8e --- /dev/null +++ b/app/assets/javascripts/lib/items/page_part.js.erb @@ -0,0 +1,141 @@ +function getPageData() { + $.getJSON("<%= Rails.application.routes.url_helpers.get_page_module_json_admin_page_parts_path %>").done(function(data) { + _pageData = data; + }); +} + +function getView(module_id, id) { + var _data = {}; + _data.val = $('#module_widget #page_part_widget_path option:selected').val(); + _data.id = id; + _data.module_id = module_id + $.ajax({ + url: "<%= Rails.application.routes.url_helpers.get_display_style_admin_page_parts_path %>", + dataType: "script", + data: _data, + contentType: "application/html; charset=utf-8", + cache: false, + }); +} + +$(function() { + $pageModule = $('#module_widget #page_part_module_app'), + $pageF2E = $('#module_widget #page_part_widget_path'), + $pageCategory = $('#module_widget #page-category'), + $pageCategoryGroup = $('#module_widget #page-category-groups'), + $pageTags = $('#module_widget #page-tags'), + $pageTagsGroup = $('#module_widget #page-tags-groups'), + $pageCount = $('#module_widget #page_count'), + _boolean = null, + _ID = null, + _type = null, + _status = null, + _pageData = null, + _selectData = null; + + $('#module_widget').on('change', '.change', function(event) { + var _data, _select, $subSelete; + if(event.target.id !== 'page_part_widget_path') { + _data = _pageData.module; + _select = _boolean ? _selectData.module : null; + $subSelete = $('#module_widget #page_part_widget_path'); + $(this).children("option:selected").each(function () { + var _val = $(this).val(); + $subSelete.empty(); + if(_val) { + $.each(_data, function(index, val) { + if(_val == val.main[1]) { + getView(val.main[1]); + $.each(val.sub, function(index, val) { + var _selected = _select && $(this)[1] == _select.sub ? 'selected="selected"' : ''; + $subSelete.append(''); + }); + $.each(val.count, function(index, val) { + $pageCount.append(''); + }); + + if(event.target.id == 'page_part_module_app') { + $pageCategory.empty(); + if(val.category.length > 0) { + $.each(val.category, function(index, val) { + if(val !== 0) { + var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : ''; + $pageCategory.append(''); + if(_select && !_select.category[0] && _arr !== -1) { + $pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true); + } + _select && _val == _select.main && _select.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : ''; + } + }); + $pageCategoryGroup.show(); + } else { + $pageCategoryGroup.hide(); + } + if(val.tags.length > 0) { + $pageTags.empty(); + $.each(val.tags, function(index, val) { + if(val !== 0) { + var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : ''; + $pageTags.append(''); + if(_select && !_select.tags[0] && _arr !== -1) { + $pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true); + } + _select && _val == _select.main && _select.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : ''; + } + }); + $pageTagsGroup.show(); + } else { + $pageTagsGroup.hide(); + } + } + return false; + }; + }); + } else { + $pageCategory.empty(); + $pageCategoryGroup.hide(); + $pageTags.empty(); + $pageTagsGroup.hide(); + $pageF2E.empty(); + $pageCount.empty(); + } + }); + } + else { + getView($pageModule.val()); + } + event.preventDefault(); + }); + + $('#module_widget').on('change', '.checkbox-groups input', function(event) { + var $checked = $(this); + if($checked.attr('type') == 'checkbox') { + if($checked.hasClass('select_all') && $checked.prop('checked')) { + $checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false); + } else if($checked.prop('checked') && !$checked.hasClass('lang-enable')) { + $checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false); + } else { + if($checked.prop('checked')) { + $checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300); + if(_status) { + var _index = $checked.closest('.link-options').find('.active').index() - 1, + _index = _type == 'page' ? _selectData.module.link[_index][1] : _linkData.link[_index][1] ; + $checked.closest('.active-link').find('.active-mune input').eq(_index).prop('checked', true); + } + } else { + $('.active-link').removeClass('active'); + $checked.closest('.active-link').find('.active-mune').slideUp(300, function() { + $(this).find('input:eq(0)').prop('checked', true); + }) + } + } + return false; + } else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) { + $('#module_widget #page_is_published_true').prop('checked') || $('#module_widget #link_is_published_true').prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300); + return false; + } + event.preventDefault(); + }); + + getPageData(); +}); \ No newline at end of file diff --git a/app/assets/javascripts/structure.js b/app/assets/javascripts/structure.js index 21b88aa36..9feeb13a0 100644 --- a/app/assets/javascripts/structure.js +++ b/app/assets/javascripts/structure.js @@ -1,5 +1,4 @@ //= require basic //= require jquery.ui.sortable //= require lib/jquery.ui.touch-punch.min.js -//= require lib/jquery.mjs.nestedSortable.js -//= require lib/items/items \ No newline at end of file +//= require lib/jquery.mjs.nestedSortable.js \ No newline at end of file diff --git a/app/assets/stylesheets/lib/main-forms.css b/app/assets/stylesheets/lib/main-forms.css index f8040157c..680e95fe1 100644 --- a/app/assets/stylesheets/lib/main-forms.css +++ b/app/assets/stylesheets/lib/main-forms.css @@ -334,6 +334,75 @@ .main-forms .control-group .add-target .btn-group .btn.last { border-radius: 0 4px 4px 0; } +.main-forms .parts-none { + width: 100%; + text-align: center; + padding: 50px 0 70px; + font-size: 2em; +} +.main-forms .display-mode .typesetting { + margin: 0 0 10px 0; +} +.main-forms .display-mode table td:last-child { + text-align: right; +} +.main-forms .display-mode .typesetting li { + display: inline-block; + float: left; + width: 120px; + position: relative; + padding: 2px; + text-align: center; +} +.main-forms .display-mode .typesetting li + li { + margin-left: 10px; +} +.main-forms .display-mode .typesetting li.active { + padding: 0; + width: 124px; +} +.main-forms .display-mode .typesetting li.active:after { + font-family: FontAwesome; + content: "\f00c"; + font-size: 12px; + text-indent: 15px; + line-height: 18px; + color: #FFF; + position: absolute; + top: 2px; + right: 2px; + width: 0px; + height: 0px; + border-style: solid; + border-width: 0 30px 30px 0; + border-color: transparent #FFA307 transparent transparent; + z-index: 1; +} +.main-forms .display-mode .typesetting li.active img { + border-radius: 5px; + background-color: #FFA307; + padding: 2px; +} +.main-forms .display-mode .typesetting img { + width: 120px; + height: 120px; +} +.main-forms .display-mode .typesetting input[type="radio"] { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0)0; + opacity: 0; + position: absolute; + width: 100%; + height: 100%; + margin: 0; +} +.main-forms .display-mode .typesetting .style_description { + display: block; + line-height: 1.2em; + font-size: 12px; + color: #686868; + padding-top: 10px; +} #user-forms .control-group .add-target .input-append input.last { border-radius: 4px; diff --git a/app/assets/stylesheets/lib/pageslide.css b/app/assets/stylesheets/lib/pageslide.css index 8eb2c90d0..4e971a4e5 100644 --- a/app/assets/stylesheets/lib/pageslide.css +++ b/app/assets/stylesheets/lib/pageslide.css @@ -70,7 +70,7 @@ } #pageslide .preview { position: relative; - /*height: 80px;*/ + height: 80px; margin: 0; padding: 0; } @@ -155,8 +155,8 @@ list-style: none; } #pageslide .typesetting li { - width: 72px; - height: 72px; + width: 60px; + height: 60px; position: relative; margin-bottom: 10px; padding: 2px; @@ -197,9 +197,13 @@ } #pageslide .typesetting .style_description { position: absolute; - width: 240%; + width: 195px; top: 0; - left: 85px; + left: 75px; + line-height: 1.1em; + font-size: 12px; + color: #E7E7E7; + padding-top: 5px; } diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index f6c9d1c78..b3ded3ade 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -19,36 +19,117 @@ class Admin::PagePartsController < OrbitBackendController def edit + # @part = PagePart.find(params[:id]) + # @r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag + # @tag_objects = @r_tag.classify.constantize.all rescue nil + # if @r_tag.eql?('tag_cloud') + # @tag_objects = ModuleApp.where(has_tag: true) + # else + # @tag_objects = @r_tag.classify.constantize.all rescue nil + # end + + # @module_apps = ModuleApp.for_widget_select + # @categories = nil + # @tags = nil + # @page_frontend_data_counts = nil + # # @frontend_styles = nil + + # @selected={ + # :module_app=> @part.module_app ? @part.module_app : nil, + # :app_frontend_url=> @part.widget_path || "default_widget", #@module_apps.first + # :category=>nil, #fetch by method: get_categories_and_tags + # :tag=>nil, #fetch by method: get_categories_and_tags + # :page_frontend_data_count=>nil, + # :frontend_style => nil, + # :widget_path=> nil + # } + + # @selected[:widget_path] = @part.widget_path ? @part.widget_path : (@selected[:module_app].widgets.keys[0] rescue nil) + # get_categories_and_tags + # get_frontend_data_count + # @app_frontend_urls = get_app_frontend_urls + # @no_orbit_bar = @side_bar = @no_header = true + + + + @id = params[:id] @part = PagePart.find(params[:id]) - @r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag - @tag_objects = @r_tag.classify.constantize.all rescue nil - if @r_tag.eql?('tag_cloud') - @tag_objects = ModuleApp.where(has_tag: true) - else - @tag_objects = @r_tag.classify.constantize.all rescue nil - end - @module_apps = ModuleApp.for_widget_select - @categories = nil - @tags = nil - @page_frontend_data_counts = nil - # @frontend_styles = nil - - @selected={ - :module_app=> @part.module_app ? @part.module_app : nil, - :app_frontend_url=> @part.widget_path || "default_widget", #@module_apps.first - :category=>nil, #fetch by method: get_categories_and_tags - :tag=>nil, #fetch by method: get_categories_and_tags - :page_frontend_data_count=>nil, - :frontend_style => nil, - :widget_path=> nil - } - - @selected[:widget_path] = @part.widget_path ? @part.widget_path : (@selected[:module_app].widgets.keys[0] rescue nil) - get_categories_and_tags - get_frontend_data_count - @app_frontend_urls = get_app_frontend_urls + @module_app = @part.module_app + if @module_app + @module_app_categories = @module_app.categories + @module_app_tags = @module_app.tags + @widget_paths = ModuleApp.find(@module_app.id).widgets.map{|name, data| [t(data["i18n"]), name]} rescue [] + if @part.widget_path.present? + if @part.widget_path.eql?("default_widget") + @checked_style = @part.widget_style + @enabled_styles = @module_app.get_default_widget["enabled_styles"] + @widget_fields = @module_app.widget_fields.collect do |widget_field| + label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}") + [label, widget_field[0], class: widget_field[2]] + end + @class_options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]} + @partial = 'default_widget' + else + @frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil + @partial = 'custom_widget' if @frontend_styles.present? + end + end + @data_count = @module_app.get_registration.get_data_count.to_a rescue [] + end @no_orbit_bar = @side_bar = @no_header = true + + + + end + + def get_page_setting_json + begin + part = PagePart.find(params[:id]) + m = {} + m["main"] = part.module_app_id.to_s + m["sub"] = part.widget_path + m["category"] = part.category.present? ? [0, part.category.map{|c| c.to_s}] : [1] + m["tags"] = part.tag.present? ? [0, part.tag.map{|c| c.to_s}] : [1] + m["count"] = part.widget_data_count + render json: JSON.pretty_generate({module: m}) + rescue + render :json => {error: ''}, status: 422 + end + end + + def get_page_module_json + modules = ModuleApp.for_widget_select.inject([]) do |module_apps, module_app| + m = {} + m["main"] = [module_app.title, module_app.id.to_s] + m["sub"] = module_app.widgets.map{|name, data| [t(data["i18n"]), name]} rescue [] + m["sub"] << [I18n.t('default_widget.default_widget'),'default_widget'] if module_app.has_default_widget? + m["category"] = module_app.categories.map{|category| [category.title, category.id.to_s] } rescue '' + m["tags"] = module_app.tags.map{|tag| [tag.name, tag.id.to_s] } rescue '' + m["count"] = module_app.get_registration.get_data_count.to_a + module_apps << m + end + render json: JSON.pretty_generate({module: modules}) + end + + def get_display_style + @part = PagePart.find(params[:id]) rescue nil + @module_app = ModuleApp.find(params[:module_id]) rescue nil + if @module_app + if params[:val].eql?("default_widget") + @checked_style = @part.widget_path.present? ? @part.widget_style : nil if @part && @part.widget_path.eql?("default_widget") + @enabled_styles = @module_app.get_default_widget["enabled_styles"] + @widget_fields = @module_app.widget_fields.collect do |widget_field| + label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}") + [label, widget_field[0], class: widget_field[2]] + end + @class_options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]} + @partial = 'default_widget' + else + @frontend_styles = @module_app.widgets[params[:val]]["style"] rescue nil + @partial = 'custom_widget' if @frontend_styles.present? + end + end end def reload_widgets diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 0dfb8ec65..8462a5dcf 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -2,6 +2,13 @@ class Admin::PagesController < Admin::ItemsController # helper Admin::PagePartsHelper # include Admin::FrontendWidgetInterface + def show + @item = Page.find(params[:id]) + @no_orbit_bar = true + @edit = true + render :text => parse_page_content(@item), :layout => 'page_layout' + end + def create @item = Page.new(params[:page]) if @item.module_app && @item.module_app.key == 'page_content' diff --git a/app/helpers/admin/frontend_widget_interface.rb b/app/helpers/admin/frontend_widget_interface.rb index e25396d80..4d9e53a46 100644 --- a/app/helpers/admin/frontend_widget_interface.rb +++ b/app/helpers/admin/frontend_widget_interface.rb @@ -19,35 +19,12 @@ protected end end - def clean_tags_and_category_params - field_name = set_field_name - if self.class==Admin::PagePartsController and params[field_name][:module_app].blank? - params[field_name][:module_app] = nil - end - if params[field_name][:tag].nil? || params[field_name][:tag].include?("nil") - params[field_name][:tag] = [] - end - - if params[field_name][:category].nil? || params[field_name][:category].include?("nil") - params[field_name][:category] = [] - end - end #of clean_tags_and_category_params - def set_local_item local_item = @part local_item = @item if local_item.nil? && @item local_item end - def set_field_name - case self.class.to_s - when "Admin::PagesController" - return "page" - when "Admin::PagePartsController" - return "page_part" - end # of case - end - def select_array_for_app_frontend_urls(hash) ary = hash.collect{|name,data| [I18n.t(data["i18n"]),name]} ary << [I18n.t('default_widget.name'),'default_widget'] if @selected[:module_app] and @selected[:module_app].has_default_widget? diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 9bf40c65d..efb41af93 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -4,7 +4,7 @@ class PagePart field :name field :content, localize: true - field :kind + field :kind, default: "none" field :public_r_tag field :public_r_tag_object_id, :default => nil field :public_r_tag_option, :default => nil diff --git a/app/views/admin/items/index.html.erb b/app/views/admin/items/index.html.erb index 68a7a2bc5..8eaa1140c 100644 --- a/app/views/admin/items/index.html.erb +++ b/app/views/admin/items/index.html.erb @@ -1,3 +1,7 @@ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/items/items" %> +<% end %> + <% node = Item.root %> <% unless node.nil? %>
+ <%= select_tag "page_part[widget_field][][field_name]", options_for_select(@widget_fields, (@part.widget_field_name[i] if @part)), include_blank: true, class: "input-large widget_field" %> + | ++ | + <%= select_tag "page_part[widget_field][][class]", options_for_select(@class_options, (@part.widget_class[i] if @part)), include_blank: true, class: "input-large" %> + | ++ + | +
<%= t "default_widget.fields_order" %> | ++ | <%= t "default_widget.fields_style" %> | ++ |
---|