Structure page with json
This commit is contained in:
		
							parent
							
								
									6d5f1a2f12
								
							
						
					
					
						commit
						a4d1c68299
					
				| 
						 | 
				
			
			@ -42,7 +42,6 @@ function customOpenSlide() {
 | 
			
		|||
  });
 | 
			
		||||
  $noiFrame = $openSlide.not('.view-page');
 | 
			
		||||
  $iFrame = $openSlide.filter('.view-page.open-slide');
 | 
			
		||||
 | 
			
		||||
  $noiFrame.pageslide({
 | 
			
		||||
    W: 314,
 | 
			
		||||
    openFn: function(pageslide, element) {
 | 
			
		||||
| 
						 | 
				
			
			@ -67,17 +66,22 @@ function customOpenSlide() {
 | 
			
		|||
             .css('display', 'inline-block')
 | 
			
		||||
             .closest('.navbar-inner')
 | 
			
		||||
             .addClass('active');
 | 
			
		||||
      _type = element.hasClass('page') ? 'page' : 'link';
 | 
			
		||||
      var _id = element.data('id'),
 | 
			
		||||
          _type = element.hasClass('page') ? 'page' : 'link',
 | 
			
		||||
          _parent = element.data('parent'),
 | 
			
		||||
          _edit = element.hasClass('edit') ? true : false;
 | 
			
		||||
 | 
			
		||||
      $('#pageslide .parent').val(_parent);
 | 
			
		||||
      if(_id !== 'new') {
 | 
			
		||||
        $('#pageslide form').attr({
 | 
			
		||||
          'action': $('#pageslide form').attr('action') + '/' + _id,
 | 
			
		||||
          'id': 'edit_' + _type + '_' + _id
 | 
			
		||||
          'id': 'edit_' + _type + '_' + _id,
 | 
			
		||||
          'method': 'put'
 | 
			
		||||
        });
 | 
			
		||||
        setForm(element.data('form'));
 | 
			
		||||
      } else {
 | 
			
		||||
        $('#pageslide form').prop('method', 'post')
 | 
			
		||||
      };
 | 
			
		||||
      _type == 'page' ? pageSetting(element.data('id'), _edit) : '';
 | 
			
		||||
      _type == 'page' ? pageSetting(element.data('id'), _edit) : linkSetting(element.data('id'), _edit);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  $iFrame.pageslide({
 | 
			
		||||
| 
						 | 
				
			
			@ -112,22 +116,30 @@ function customOpenSlide() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function pageSetting(id, edit) {
 | 
			
		||||
  $pageModule = $('#page_module_app_id'),
 | 
			
		||||
  $pageF2E = $('#page_app_frontend_url'),
 | 
			
		||||
  $pageDesign = $('#page_design'),
 | 
			
		||||
  $pageTheme = $('#page_theme_id'),
 | 
			
		||||
  $pageCategory = $('#page-category'),
 | 
			
		||||
  $pageTags = $('#page-tags');
 | 
			
		||||
  if(edit) {
 | 
			
		||||
  $pageModule = $('#pageslide #page_module_app_id');
 | 
			
		||||
  $pageF2E = $('#pageslide #page_app_frontend_url');
 | 
			
		||||
  $pageDivF2E = $('#pageslide #front_url');
 | 
			
		||||
  $pageDesign = $('#pageslide #page_design');
 | 
			
		||||
  $pageTheme = $('#pageslide #page_theme_id');
 | 
			
		||||
  $pageCategory = $('#pageslide #page-category');
 | 
			
		||||
  $pageCategoryGroup = $('#pageslide #page-category-groups');
 | 
			
		||||
  $pageTags = $('#pageslide #page-tags');
 | 
			
		||||
  $pageTagsGroup = $('#pageslide #page-tags-groups');
 | 
			
		||||
  $pagePublishedTrue = $('#pageslide #page_is_published_true');
 | 
			
		||||
  $pageCount = $('#pageslide #page_count');
 | 
			
		||||
  $pageDivCount = $('#pageslide #front_count');
 | 
			
		||||
  _status = edit;
 | 
			
		||||
  _ID = id;
 | 
			
		||||
  if(_status) {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
      url: 'page-setting.json',
 | 
			
		||||
      type: 'POST',
 | 
			
		||||
      url: "<%= Rails.application.routes.url_helpers.get_page_setting_json_admin_pages_path %>",
 | 
			
		||||
      contentType: "application/json; charset=utf-8",
 | 
			
		||||
      dataType: 'json',
 | 
			
		||||
      data: '{"id": ' + id + '}',
 | 
			
		||||
      data: {id: id},
 | 
			
		||||
      cache: false,
 | 
			
		||||
    })
 | 
			
		||||
    .done(function(data) {
 | 
			
		||||
      _boolean = true;
 | 
			
		||||
      _selectData = data;
 | 
			
		||||
      $.each(_pageData.design, function(index, val) {
 | 
			
		||||
        $pageDesign.append('<option value="' + val.main[1] + '" ' + (val.main[1] == _selectData.design.main ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
 | 
			
		||||
| 
						 | 
				
			
			@ -137,31 +149,52 @@ function pageSetting(id, edit) {
 | 
			
		|||
          });
 | 
			
		||||
        };
 | 
			
		||||
      });
 | 
			
		||||
      $pageModule.append('<option/>');
 | 
			
		||||
      $.each(_pageData.module, function(index, val) {
 | 
			
		||||
        $pageModule.append('<option value="' + val.main[1] + '" ' + (val.main[1] == _selectData.module.main ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
 | 
			
		||||
        if(val.main[1] == _selectData.module.main) {
 | 
			
		||||
        if(_selectData.module.main && val.main[1] == _selectData.module.main) {
 | 
			
		||||
          $pageDivF2E.show();
 | 
			
		||||
          $.each(val.sub, function(index, val) {
 | 
			
		||||
            $pageF2E.append('<option value="' + $(this)[1] + '" ' + ($(this)[1] == _selectData.module.sub ? 'selected="selected"' : '') + '>' + $(this)[0]+ '</option>')
 | 
			
		||||
          });
 | 
			
		||||
          $.each(val.category, function(index, val) {
 | 
			
		||||
            var _arr = $.inArray($(this)[1], _selectData.module.category[1]);
 | 
			
		||||
            $pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
            if(!_selectData.module.category[0] && _arr !== -1) {
 | 
			
		||||
              $pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
 | 
			
		||||
            }
 | 
			
		||||
            _selectData.module.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
 | 
			
		||||
          });
 | 
			
		||||
          $.each(val.tags, function(index, val) {
 | 
			
		||||
            var _arr = $.inArray($(this)[1], _selectData.module.tags[1]);
 | 
			
		||||
            $pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
            if(!_selectData.module.tags[0] && _arr !== -1) {
 | 
			
		||||
              $pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
 | 
			
		||||
            }
 | 
			
		||||
            _selectData.module.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
 | 
			
		||||
          $.each(val.count, function(index, val) {
 | 
			
		||||
            $pageCount.append('<option value="' + val + '" ' + (val == _selectData.module.count ? 'selected="selected"' : '') + '>' + val+ '</option>');
 | 
			
		||||
          });
 | 
			
		||||
          $pageDivCount.show();
 | 
			
		||||
 | 
			
		||||
          if(val.category.length > 0) {
 | 
			
		||||
            $.each(val.category, function(index, val) {
 | 
			
		||||
              var _arr = $.inArray($(this)[1], _selectData.module.category[1]);
 | 
			
		||||
              $pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
              if(!_selectData.module.category[0] && _arr !== -1) {
 | 
			
		||||
                $pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
 | 
			
		||||
              }
 | 
			
		||||
              _selectData.module.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
 | 
			
		||||
            });
 | 
			
		||||
            $pageCategoryGroup.show();
 | 
			
		||||
          }
 | 
			
		||||
          if(val.category.length > 0) {
 | 
			
		||||
            $.each(val.tags, function(index, val) {
 | 
			
		||||
              var _arr = $.inArray($(this)[1], _selectData.module.tags[1]);
 | 
			
		||||
              $pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
              if(!_selectData.module.tags[0] && _arr !== -1) {
 | 
			
		||||
                $pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
 | 
			
		||||
              }
 | 
			
		||||
              _selectData.module.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
 | 
			
		||||
            });
 | 
			
		||||
            $pageTagsGroup.show();
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
      });
 | 
			
		||||
      changeSetting(true);
 | 
			
		||||
      _selectData.module.public ? $pagePublishedTrue.prop('checked', true) : $pagePublishedTrue.prop('checked', false);
 | 
			
		||||
      $.each(_selectData.module.link, function(index, val) {
 | 
			
		||||
        if(val[1]) {
 | 
			
		||||
          $('#pageslide .active-link.' + val[0]).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
 | 
			
		||||
          $('#pageslide .active-link.' + val[0]).find('input[type="radio"]').eq(val[2]).prop('checked', true);
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      changeSetting(id);
 | 
			
		||||
      $('#pageslide').find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
 | 
			
		||||
    })
 | 
			
		||||
    .fail(function(jqXHR, textStatus) {
 | 
			
		||||
      console.log(jqXHR.status, textStatus)
 | 
			
		||||
| 
						 | 
				
			
			@ -169,117 +202,112 @@ function pageSetting(id, edit) {
 | 
			
		|||
      $('#pageslide .view-page').append($errorMsg);
 | 
			
		||||
    });
 | 
			
		||||
  } else {
 | 
			
		||||
    _boolean = false;
 | 
			
		||||
    $.each(_pageData.design, function(index, val) {
 | 
			
		||||
      $pageDesign.append('<option value="' + val.main[1] + '">' + val.main[0] + '</option>');
 | 
			
		||||
      if(index == 0) {
 | 
			
		||||
      $pageDesign.append('<option value="' + val.main[1] + '" ' + (val.main[2] ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
 | 
			
		||||
      if(val.main[2]) {
 | 
			
		||||
        $.each(val.sub, function(index, val) {
 | 
			
		||||
          $pageTheme.append('<option value="' + $(this)[1] + '">' + $(this)[0]+ '</option>')
 | 
			
		||||
        });
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
    $pageModule.append('<option/>');
 | 
			
		||||
    $.each(_pageData.module, function(index, val) {
 | 
			
		||||
      $pageModule.append('<option value="' + val.main[1] + '">' + val.main[0] + '</option>');
 | 
			
		||||
      if(index == 0) {
 | 
			
		||||
        $.each(val.sub, function(index, val) {
 | 
			
		||||
          $pageF2E.append('<option value="' + $(this)[1] + '">' + $(this)[0]+ '</option>')
 | 
			
		||||
        });
 | 
			
		||||
        $.each(val.category, function(index, val) {
 | 
			
		||||
          $pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
        });
 | 
			
		||||
        $.each(val.tags, function(index, val) {
 | 
			
		||||
          $pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
        });
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
    changeSetting(false);
 | 
			
		||||
    changeSetting(id);
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function changeSetting(boolean) {
 | 
			
		||||
  $('#pageslide').on('change', '.change', function(event) {
 | 
			
		||||
    var _data, _select, _subData, $subSelete;
 | 
			
		||||
 | 
			
		||||
    if(event.target.id == 'page_design') {
 | 
			
		||||
      _data = _pageData.design;
 | 
			
		||||
      _select = boolean ? _selectData.design : null;
 | 
			
		||||
      _subData = 'template';
 | 
			
		||||
      $subSelete = $('#page_theme_id');
 | 
			
		||||
    } else {
 | 
			
		||||
      _data = _pageData.module;
 | 
			
		||||
      _select = boolean ? _selectData.module : null;
 | 
			
		||||
      _subData = 'module';
 | 
			
		||||
      $subSelete = $('#page_app_frontend_url');
 | 
			
		||||
    };
 | 
			
		||||
    $(this).children("option:selected").each(function () {
 | 
			
		||||
      var _val = $(this).val();
 | 
			
		||||
      $subSelete.empty();
 | 
			
		||||
      $.each(_data, function(index, val) {
 | 
			
		||||
        if(_val == val.main[1]) {
 | 
			
		||||
          $.each(val.sub, function(index, val) {
 | 
			
		||||
            var _selected = _select && $(this)[1] == _select.sub ? 'selected="selected"' : '';
 | 
			
		||||
            $subSelete.append('<option value="' + $(this)[1] + '" ' + _selected + '>' + $(this)[0] + '</option>');
 | 
			
		||||
          });
 | 
			
		||||
          if(event.target.id == 'page_module_app_id') {
 | 
			
		||||
            $pageCategory.empty();
 | 
			
		||||
            $pageTags.empty();
 | 
			
		||||
            $('.select_all').prop('checked', false)
 | 
			
		||||
            $.each(val.category, function(index, val) {
 | 
			
		||||
              if(val !== 0) {
 | 
			
		||||
                $('#page-category-groups').slideDown(300);
 | 
			
		||||
                var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : '';
 | 
			
		||||
                $pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
                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) : '';
 | 
			
		||||
              } else {
 | 
			
		||||
                $('#page-category-groups').slideUp(300);
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
            $.each(val.tags, function(index, val) {
 | 
			
		||||
              if(val !== 0) {
 | 
			
		||||
                $('#page-tags-groups').slideDown(300);
 | 
			
		||||
                var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
 | 
			
		||||
                $pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
                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) : '';
 | 
			
		||||
              } else {
 | 
			
		||||
                $('#page-tags-groups').slideUp(300);
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
          return false;
 | 
			
		||||
function linkSetting(id, edit) {
 | 
			
		||||
  $linkKey = $('#pageslide .link-key');
 | 
			
		||||
  $linkUrl = $('#pageslide .link-url');
 | 
			
		||||
  $linkTitle = $('#pageslide .link-title'),
 | 
			
		||||
  $linkPublishedTrue = $('#link_is_published_true');
 | 
			
		||||
  _status = edit;
 | 
			
		||||
  if(_status) {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
      url: 'link-setting.json',
 | 
			
		||||
      type: 'POST',
 | 
			
		||||
      contentType: "application/json; charset=utf-8",
 | 
			
		||||
      dataType: 'json',
 | 
			
		||||
      data: '{"id": ' + id + '}',
 | 
			
		||||
      cache: false,
 | 
			
		||||
    })
 | 
			
		||||
    .done(function(data) {
 | 
			
		||||
      _linkData = data;
 | 
			
		||||
      $linkKey.val(data.key);
 | 
			
		||||
      $.each(data.url, function(index, val) {
 | 
			
		||||
         $linkUrl.eq(index).val(val)
 | 
			
		||||
      });
 | 
			
		||||
      $.each(data.title, function(index, val) {
 | 
			
		||||
         $linkTitle.eq(index).val(val)
 | 
			
		||||
      });
 | 
			
		||||
      data.public ? $linkPublishedTrue.prop('checked', true) : $linkPublishedTrue.prop('checked', false);
 | 
			
		||||
      $linkPublishedTrue.prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
 | 
			
		||||
      $.each(data.link, function(index, val) {
 | 
			
		||||
        if(val[0]) {
 | 
			
		||||
          $('.active-link').eq(index).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
 | 
			
		||||
          val[1] == 1 ? $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true) : $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true);
 | 
			
		||||
        };
 | 
			
		||||
      });
 | 
			
		||||
      $('#pageslide').find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
 | 
			
		||||
    })
 | 
			
		||||
    .fail(function(jqXHR, textStatus) {
 | 
			
		||||
      console.log(jqXHR.status, textStatus)
 | 
			
		||||
      var $errorMsg = '<div class="error-cover"><div class="msg"><i class="icons-warning"></i><p>Sorry! Something is wrong</p></div></div>'
 | 
			
		||||
      $('#pageslide .view-page').append($errorMsg);
 | 
			
		||||
    });
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
  });
 | 
			
		||||
  $('#pageslide').on('change', '.checkbox-groups input[type="checkbox"]', function(event) {
 | 
			
		||||
    if($(this).hasClass('select_all') && $(this).prop('checked')) {
 | 
			
		||||
      $(this).closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
 | 
			
		||||
    } else if($(this).prop('checked')) {
 | 
			
		||||
      $(this).closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false);
 | 
			
		||||
    }
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
  });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function changeSetting(id) {
 | 
			
		||||
  getView(id);
 | 
			
		||||
  $pagePublishedTrue.prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getPageData() {
 | 
			
		||||
  $.getJSON('page-design-module.json').done(function(data) {
 | 
			
		||||
  $.getJSON("<%= Rails.application.routes.url_helpers.get_page_design_module_json_admin_items_path %>").done(function(data) {
 | 
			
		||||
    _pageData = data;
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
function getView(id) {
 | 
			
		||||
  var _data = {};
 | 
			
		||||
      _data.val = $('#pageslide #page_app_frontend_url option:selected').val();
 | 
			
		||||
      _data.id = id;
 | 
			
		||||
      $.ajax({
 | 
			
		||||
        url: "<%#= Rails.application.routes.url_helpers.get_display_style_admin_pages_path %>",
 | 
			
		||||
        dataType: "html",
 | 
			
		||||
        data: _data,
 | 
			
		||||
        contentType: "application/html; charset=utf-8",
 | 
			
		||||
        cache: false,
 | 
			
		||||
      });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(function(){
 | 
			
		||||
  var $pageModule = null,
 | 
			
		||||
      $pageF2E = null,
 | 
			
		||||
      $pageDesign = null,
 | 
			
		||||
      $pageTheme = null,
 | 
			
		||||
      $pageCategory = null,
 | 
			
		||||
      $pageTags = null;
 | 
			
		||||
      _pageData = null;
 | 
			
		||||
      _selectData = null;
 | 
			
		||||
$(function() {
 | 
			
		||||
  $pageModule = null,
 | 
			
		||||
  $pageF2E = null,
 | 
			
		||||
  $pageDivF2E = null,
 | 
			
		||||
  $pageDesign = null,
 | 
			
		||||
  $pageTheme = null,
 | 
			
		||||
  $pageCategory = null,
 | 
			
		||||
  $pageCategoryGroup = null,
 | 
			
		||||
  $pageTags = null,
 | 
			
		||||
  $pageTagsGroup = null,
 | 
			
		||||
  $pagePublishedTrue = null,
 | 
			
		||||
  $pageCount = null,
 | 
			
		||||
  $pageDivCount = null,
 | 
			
		||||
  $linkKey = null,
 | 
			
		||||
  $linkUrl = null,
 | 
			
		||||
  $linkTitle = null,
 | 
			
		||||
  $linkPublishedTrue = null,  
 | 
			
		||||
  _boolean = null,
 | 
			
		||||
  _ID = null,
 | 
			
		||||
  _type = null,
 | 
			
		||||
  _status = null,
 | 
			
		||||
  _pageData = null,
 | 
			
		||||
  _selectData = null,
 | 
			
		||||
  _linkData = null;
 | 
			
		||||
  $('.sortable').nestedSortable({
 | 
			
		||||
    handle: '.brand',
 | 
			
		||||
    items: 'li',
 | 
			
		||||
| 
						 | 
				
			
			@ -296,7 +324,7 @@ $(function(){
 | 
			
		|||
      } else {
 | 
			
		||||
        position = $(ui.item).index();
 | 
			
		||||
      };
 | 
			
		||||
      $.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: (ui.item.parent().closest('li').attr('id') || ui.item.parent().closest('ol').attr('id')), position: position } );
 | 
			
		||||
      $.post("<%= Rails.application.routes.url_helpers.update_position_admin_items_path %>", { id: ui.item.attr('id'), parent_id: (ui.item.parent().closest('li').attr('id') || ui.item.parent().closest('ol').attr('id')), position: position } );
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  $(".sortable").delegate(".brand, .delete", clickEvent, function(e){
 | 
			
		||||
| 
						 | 
				
			
			@ -311,7 +339,136 @@ $(function(){
 | 
			
		|||
    }
 | 
			
		||||
    e.preventDefault();
 | 
			
		||||
  });
 | 
			
		||||
  $("#dialog").on('show', function (e) {
 | 
			
		||||
    $(this).find('.delete-item').on(clickEvent, function() {
 | 
			
		||||
      $target.parents('.navbar').parent('li').remove();
 | 
			
		||||
      $('ol').not('.sortable').each(function() {
 | 
			
		||||
        if($(this).children('li').index() == -1) {
 | 
			
		||||
          $(this).remove();
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      itemsQuantity();
 | 
			
		||||
      $('#dialog').modal('hide');
 | 
			
		||||
      e.preventDefault();
 | 
			
		||||
    })
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  $('#pageslide').on('change', '.change', function(event) {
 | 
			
		||||
    var _data, _select, _subData, $subSelete;
 | 
			
		||||
    if(event.target.id !== 'page_app_frontend_url') {
 | 
			
		||||
      if(event.target.id == 'page_design') {
 | 
			
		||||
        _data = _pageData.design;
 | 
			
		||||
        _select = _boolean ? _selectData.design : null;
 | 
			
		||||
        _subData = 'template';
 | 
			
		||||
        $subSelete = $('#pageslide #page_theme_id');
 | 
			
		||||
      } else {
 | 
			
		||||
        _data = _pageData.module;
 | 
			
		||||
        _select = _boolean ? _selectData.module : null;
 | 
			
		||||
        _subData = 'module';
 | 
			
		||||
        $subSelete = $('#pageslide #page_app_frontend_url');
 | 
			
		||||
      };
 | 
			
		||||
      $(this).children("option:selected").each(function () {
 | 
			
		||||
        var _val = $(this).val();
 | 
			
		||||
        $subSelete.empty();
 | 
			
		||||
        if(_val) {
 | 
			
		||||
          $.each(_data, function(index, val) {
 | 
			
		||||
            if(_val == val.main[1]) {
 | 
			
		||||
              $pageDivF2E.show();
 | 
			
		||||
              $.each(val.sub, function(index, val) {
 | 
			
		||||
                var _selected = _select && $(this)[1] == _select.sub ? 'selected="selected"' : '';
 | 
			
		||||
                $subSelete.append('<option value="' + $(this)[1] + '" ' + _selected + '>' + $(this)[0] + '</option>');
 | 
			
		||||
              });
 | 
			
		||||
              $.each(val.count, function(index, val) {
 | 
			
		||||
                $pageCount.append('<option value="' + val + '" ' + (_select.main == _val && val == _selectData.module.count ? 'selected="selected"' : '') + '>' + val+ '</option>');
 | 
			
		||||
              });
 | 
			
		||||
              $pageDivCount.show();
 | 
			
		||||
 | 
			
		||||
              if(event.target.id == 'page_module_app_id') {
 | 
			
		||||
                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('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
                      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 {
 | 
			
		||||
                  $pageCategory.empty();
 | 
			
		||||
                  $pageCategoryGroup.hide();
 | 
			
		||||
                }
 | 
			
		||||
                if(val.tags.length > 0) {
 | 
			
		||||
                  $.each(val.tags, function(index, val) {
 | 
			
		||||
                    if(val !== 0) {
 | 
			
		||||
                      var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
 | 
			
		||||
                      $pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
 | 
			
		||||
                      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 {
 | 
			
		||||
                  $pageTags.empty();
 | 
			
		||||
                  $pageTagsGroup.hide();
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
              return false;
 | 
			
		||||
            };
 | 
			
		||||
          });
 | 
			
		||||
        } else {
 | 
			
		||||
          $pageCategory.empty();
 | 
			
		||||
          $pageCategoryGroup.hide();
 | 
			
		||||
          $pageTags.empty();
 | 
			
		||||
          $pageTagsGroup.hide();
 | 
			
		||||
          $pageF2E.empty();
 | 
			
		||||
          $pageDivF2E.hide();
 | 
			
		||||
          $pageCount.empty();
 | 
			
		||||
          $pageDivCount.hide();
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    } else {
 | 
			
		||||
      getView(_ID);
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  $('#pageslide').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')) {
 | 
			
		||||
      $('#pageslide #page_is_published_true').prop('checked') || $('#pageslide #link_is_published_true').prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    event.preventDefault();
 | 
			
		||||
  });
 | 
			
		||||
  tip();
 | 
			
		||||
  touchSupport()
 | 
			
		||||
  itemsQuantity();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,4 @@
 | 
			
		|||
//= require jquery.ui.sortable
 | 
			
		||||
//= require lib/jquery.ui.touch-punch.min.js
 | 
			
		||||
//= require lib/jquery.mjs.nestedSortable.js
 | 
			
		||||
//= require lib/items/items
 | 
			
		||||
//= require lib/items/update_cates_and_tags
 | 
			
		||||
//= require lib/items/page_widget_edit_interface
 | 
			
		||||
//= require lib/items/items
 | 
			
		||||
| 
						 | 
				
			
			@ -25,5 +25,25 @@ class Admin::ItemsController < OrbitBackendController
 | 
			
		|||
    item.shift_to(params[:parent_id], params[:position].to_i)
 | 
			
		||||
    render :nothing => true, status: 200
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def get_page_design_module_json
 | 
			
		||||
    designs = Design.all.inject([]) do |designs, design|
 | 
			
		||||
      d = {}
 | 
			
		||||
      d["main"] = [design.title, design.id.to_s, (design.site.present? ? 1 : 0)]
 | 
			
		||||
      d["sub"] = design.themes.map{|theme| [theme.name, theme.id.to_s]} rescue ''
 | 
			
		||||
      designs << d
 | 
			
		||||
    end
 | 
			
		||||
    modules = ModuleApp.for_frontend_select.inject([]) do |module_apps, module_app|
 | 
			
		||||
      m = {}
 | 
			
		||||
      m["main"] = [module_app.title, module_app.id.to_s]
 | 
			
		||||
      m["sub"] = module_app.app_pages.map{|name, data| [t(data["i18n"]), name]} rescue []
 | 
			
		||||
      m["sub"] << [I18n.t('default_widget.name'),'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({design: designs, module: modules})
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,8 @@ class Admin::PagesController < Admin::ItemsController
 | 
			
		|||
  helper Admin::PagePartsHelper
 | 
			
		||||
  include Admin::FrontendWidgetInterface
 | 
			
		||||
 | 
			
		||||
  include ActionView::Helpers::DynamicForm
 | 
			
		||||
 | 
			
		||||
  def show
 | 
			
		||||
    @item = Page.find(params[:id])
 | 
			
		||||
    @no_orbit_bar = true
 | 
			
		||||
| 
						 | 
				
			
			@ -128,18 +130,35 @@ class Admin::PagesController < Admin::ItemsController
 | 
			
		|||
  def update
 | 
			
		||||
    clean_tags_and_category_params
 | 
			
		||||
    @item = Page.find(params[:id])
 | 
			
		||||
 | 
			
		||||
    if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
 | 
			
		||||
      @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
 | 
			
		||||
    end
 | 
			
		||||
    if @item.update_attributes(params[:page])
 | 
			
		||||
      flash[:notice] = t('update.success.page')
 | 
			
		||||
      respond_to do |format|
 | 
			
		||||
        format.js { render 'admin/items/reload_items' }
 | 
			
		||||
    unless @item.update_attributes(params[:page])
 | 
			
		||||
      @error = error_messages_for(@item)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def get_display_style
 | 
			
		||||
    
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def get_page_setting_json
 | 
			
		||||
    begin
 | 
			
		||||
      page = Page.find(params[:id])
 | 
			
		||||
      design = {main: page.design_id.to_s, sub: page.theme_id.to_s}
 | 
			
		||||
      m = {}
 | 
			
		||||
      m["main"] = page.module_app_id.to_s
 | 
			
		||||
      m["sub"] = page.app_frontend_url
 | 
			
		||||
      m["category"] = page.category.present? ? [0, page.category.map{|c| c.to_s}] : [1]
 | 
			
		||||
      m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1]
 | 
			
		||||
      m["public"] = page.is_published ? 1 : 0
 | 
			
		||||
      m["link"] = @site_valid_locales.inject([]) do |link, locale|
 | 
			
		||||
        link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale]) ? 1 :0]
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      get_variables_for_edit
 | 
			
		||||
      render :action => "edit"
 | 
			
		||||
      m["count"] = page.frontend_data_count 
 | 
			
		||||
      render json: JSON.pretty_generate({design: design, module: m})
 | 
			
		||||
    rescue
 | 
			
		||||
      render :json => {error: 'hahah'}, status: 422
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@ class Item
 | 
			
		|||
  field :path
 | 
			
		||||
  field :is_published, :type => Boolean, :default => false
 | 
			
		||||
  field :enabled_for, :type => Array, :default => nil
 | 
			
		||||
  field :menu_enabled_for, :type => Array, :default => nil
 | 
			
		||||
  field :menu_enabled_for, :type => Hash, :default => nil
 | 
			
		||||
  field :title, localize: true
 | 
			
		||||
  field :sitemap_enabled, :type => Hash, :default => {}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,5 +11,5 @@
 | 
			
		|||
	</td>
 | 
			
		||||
  <td class="span7"><%= design.intro %></td>
 | 
			
		||||
  <td class="span2"><%= design.author %></td>
 | 
			
		||||
  <td class="span1 active"><%= radio_button_tag 'design_default', design.id, (@site.design.id.to_s.eql?(design.id.to_s) ? true : false), :class => 'design_default toggle-check', :rel => admin_sites_path %></td>
 | 
			
		||||
  <td class="span1 active"><%= radio_button_tag 'design_default', design.id, (@site.design && @site.design.id.to_s.eql?(design.id.to_s) ? true : false), :class => 'design_default toggle-check', :rel => admin_sites_path %></td>
 | 
			
		||||
</tr>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,92 @@
 | 
			
		|||
<div id="page" class="hide">
 | 
			
		||||
  <%= form_for :page, url: admin_pages_path, remote: true do |f| %>
 | 
			
		||||
    <fieldset>
 | 
			
		||||
      <div id="page_error"></div>
 | 
			
		||||
      <%= f.hidden_field :parent, class: "parent" %>
 | 
			
		||||
      <%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:name) %>
 | 
			
		||||
      <%= f.text_field :name, class: 'input-xlarge', placeholder: t(:name), id: 'name' %>
 | 
			
		||||
      <span class="help-block"><%= t("front_page.name_field_helper") %></span>
 | 
			
		||||
 | 
			
		||||
      <%= f.fields_for :title_translations do |f| %>
 | 
			
		||||
        <% @site_valid_locales.each do |locale| %>
 | 
			
		||||
          <%= f.label :locale, "#{t(:title)} #{I18nVariable.from_locale(locale)}" %>
 | 
			
		||||
          <%= f.text_field locale, class: 'input-xlarge', placeholder: "#{t(:title)} #{I18nVariable.from_locale(locale)}", id: locale %>
 | 
			
		||||
        <% end %>
 | 
			
		||||
      <% end %>
 | 
			
		||||
 | 
			
		||||
      <%= f.label :design, t(:template_name) %>
 | 
			
		||||
      <%= select_tag "page[design]", nil, class: "input-xlarge change" %>
 | 
			
		||||
 | 
			
		||||
      <%= f.label :theme, t(:theme) %>
 | 
			
		||||
      <%= select_tag "page[theme_id]", nil, class: "input-xlarge" %>
 | 
			
		||||
 | 
			
		||||
      <%= f.label :module_app_id, t(:module) %>
 | 
			
		||||
      <%= select_tag "page[module_app_id]", nil, class: "input-xlarge change" %>
 | 
			
		||||
 | 
			
		||||
      <div id="front_url" class="hide">
 | 
			
		||||
        <%= f.label :app_frontend_url, t('front_page.display_mode') %>
 | 
			
		||||
        <%= select_tag "page[app_frontend_url]", nil, class: "input-xlarge change" %>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="checkbox-groups hide" id="page-category-groups">
 | 
			
		||||
        <%= f.label :categories, t(:categories) %>
 | 
			
		||||
        <%= content_tag :label, class: "checkbox" do %>
 | 
			
		||||
          <%= check_box_tag nil, nil, false, class: "select_all" %> <%= t(:all) %>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <div class="groups" id="page-category"></div>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="checkbox-groups hide" id="page-tags-groups">
 | 
			
		||||
        <%= f.label :tags, t(:tags) %>
 | 
			
		||||
        <%= content_tag :label, class: "checkbox" do %>
 | 
			
		||||
          <%= check_box_tag nil, nil, false, class: "select_all" %> <%= t(:all) %>
 | 
			
		||||
        <% end %>
 | 
			
		||||
        <div class="groups" id="page-tags"></div>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="display-mode"></div>
 | 
			
		||||
 | 
			
		||||
      <div id="front_count" class="hide">
 | 
			
		||||
        <%= f.label :frontend_data_count, t(:frontend_data_count) %>
 | 
			
		||||
        <%= select_tag "page[frontend_data_count]", nil, class: "input-mini change", id: "page_count" %>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="checkbox-groups" id="page-is-published">
 | 
			
		||||
        <%= f.label :is_published, t(:is_published) %>
 | 
			
		||||
        <p>
 | 
			
		||||
          <label class="radio inline">
 | 
			
		||||
            <%= f.radio_button :is_published, true %> <%= t(:yes_) %>
 | 
			
		||||
          </label>
 | 
			
		||||
          <label class="radio inline">
 | 
			
		||||
            <%= f.radio_button :is_published, false, checked: "checked" %> <%= t(:no_) %>
 | 
			
		||||
          </label>
 | 
			
		||||
        </p>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="link-options checkbox-groups">
 | 
			
		||||
        <label><%= t(:activation_link) %></label>
 | 
			
		||||
        <% @site_valid_locales.each do |valid_locale| %>
 | 
			
		||||
          <div class="active-link <%= valid_locale %>">
 | 
			
		||||
            <label class="checkbox">
 | 
			
		||||
              <%= check_box_tag 'page[enabled_for][]', valid_locale, false, class: "lang-enable" %> <%= I18nVariable.from_locale(valid_locale) %>
 | 
			
		||||
            </label>
 | 
			
		||||
            <div class="active-mune">
 | 
			
		||||
              <span><%= t(:menu_enable) %></span>
 | 
			
		||||
              <label class="radio inline">
 | 
			
		||||
                <%= radio_button_tag "page[menu_enabled_for][#{valid_locale}]", false, true %> <%= t(:no_) %>
 | 
			
		||||
              </label>
 | 
			
		||||
              <label class="radio inline">
 | 
			
		||||
                <%= radio_button_tag "page[menu_enabled_for][#{valid_locale}]", true, false %> <%= t(:yes_) %>
 | 
			
		||||
              </label>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        <% end %>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="form-actions">
 | 
			
		||||
        <a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
 | 
			
		||||
        <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
 | 
			
		||||
      </div>
 | 
			
		||||
    </fieldset>
 | 
			
		||||
  <% end %>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -18,15 +18,15 @@
 | 
			
		|||
      <% end %>
 | 
			
		||||
      <div class="item-menu">
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icon-eye-open"), "/#{node.path}?edit=true", class: "view-page open-slide tip", title: t(:view), data: {title: node.title} if node.class.to_s.eql?('Page') %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icon-edit"), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), class: "open-slide tip #{node.class.to_s.downcase} edit", title: t(:edit), data: {title: t(:edit)} %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_admin_page_path(:parent_id => node.id), class: "open-slide tip page", title: t(:add_page), data: {title: t(:add_page)} if node.class.to_s.eql?('Page') %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icon-edit"), "#page", class: "open-slide tip #{node.class.to_s.downcase} edit", title: t(:edit), data: {title: t(:edit), id: node.id.to_s, parent: node.parent_id.to_s, form: {name: node.name}.merge(node.title_translations)} %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icons-newspaper"), "#page", class: "open-slide tip page", title: t(:add_page), data: {title: t(:add_page), id: 'new', parent: node.parent_id.to_s} if node.class.to_s.eql?('Page') %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icon-link"), new_admin_link_path(:parent_id => node.id), class: "open-slide tip link", title: t(:add_link), data: {title: t(:add_link)} if node.class.to_s.eql?('Page') %>
 | 
			
		||||
        <%= link_to content_tag(:i, nil, class: "icon-trash"), nil, rel: eval("admin_#{node.class.to_s.downcase}_path(node)"), class: "delete tip", title: t(:delete_), data: {title: t(:delete_)} unless node.root? %>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="item-info pull-right">
 | 
			
		||||
      <% @site_valid_locales.each do |valid_locale| %>
 | 
			
		||||
        <% if node.menu_enabled_for.include?(valid_locale) %>
 | 
			
		||||
        <% if node.enabled_for && node.enabled_for.include?(valid_locale) %>
 | 
			
		||||
          <span class="label label-warning"><%= I18nVariable.from_locale(valid_locale) %></span>
 | 
			
		||||
          |
 | 
			
		||||
        <% end %>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,5 +5,5 @@
 | 
			
		|||
</ol>
 | 
			
		||||
<% end %>
 | 
			
		||||
<%= render 'layouts/delete_modal', delete_options: {remote: true} %>
 | 
			
		||||
 | 
			
		||||
<%= render 'form_page' %>
 | 
			
		||||
<%= javascript_include_tag "lib/pageslide.js" %>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
<%= form_for @item, url: admin_pages_path, remote: true do |f| %>
 | 
			
		||||
  <fieldset>
 | 
			
		||||
    <legend><%= t('new.page') %></legend>
 | 
			
		||||
    <%= render :partial => "form", :locals => { :f => f } %>
 | 
			
		||||
    <div class="form-actions">
 | 
			
		||||
      <a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
<% if @error %>
 | 
			
		||||
	$("#pageslide #page_error").html("<%= j @error %>");
 | 
			
		||||
<% else %>
 | 
			
		||||
	$("#<%= @item.id.to_s %>").html("<%= j render 'admin/items/node_and_children', node: @item %>");
 | 
			
		||||
	reloadStructure();
 | 
			
		||||
<% end %>
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ en:
 | 
			
		|||
  forgot_password: Forgot your password?
 | 
			
		||||
  frequency: Frequency
 | 
			
		||||
  front_page:
 | 
			
		||||
    name_field_helper: Can not be blank
 | 
			
		||||
    name_field_helper: Please enter a number or English, can not use a spacing
 | 
			
		||||
    select_app_url: 
 | 
			
		||||
    is_published: 
 | 
			
		||||
    menu_enable_lang: 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
en:
 | 
			
		||||
  activation_link: Activation Link
 | 
			
		||||
  add_category: Add category
 | 
			
		||||
  add_link: Add link
 | 
			
		||||
  add_page: Add page
 | 
			
		||||
| 
						 | 
				
			
			@ -23,12 +24,14 @@ en:
 | 
			
		|||
  file:
 | 
			
		||||
    name: File name
 | 
			
		||||
  front_page:
 | 
			
		||||
    display_mode: Display mode
 | 
			
		||||
    name_language: Site Title
 | 
			
		||||
    select_template: Select Template
 | 
			
		||||
    select_themes: Select Themes
 | 
			
		||||
    select_module: Select Module
 | 
			
		||||
  language: Language
 | 
			
		||||
  login_orbit: Log In to Orbit
 | 
			
		||||
  menu_enable: Menu Enable
 | 
			
		||||
  merge: Merge
 | 
			
		||||
  new:
 | 
			
		||||
    tag: New tag
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,9 +86,13 @@ Orbit::Application.routes.draw do
 | 
			
		|||
      get 'add_attribute_field'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    resources :items
 | 
			
		||||
    resources :items do
 | 
			
		||||
      collection do
 | 
			
		||||
        get 'get_page_design_module_json'
 | 
			
		||||
        post 'update_position'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    match 'update_position' => 'items#update_position'
 | 
			
		||||
    resources :links do
 | 
			
		||||
      member do
 | 
			
		||||
        get 'delete'
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +101,8 @@ Orbit::Application.routes.draw do
 | 
			
		|||
 | 
			
		||||
    resources :pages do
 | 
			
		||||
      collection do
 | 
			
		||||
        get 'get_display_style'
 | 
			
		||||
        get 'get_page_setting_json'
 | 
			
		||||
        get 'reload_themes'
 | 
			
		||||
        get 'reload_after_module_changed', :action=>'reload_frontend_pages'
 | 
			
		||||
        get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@ namespace :new_ui do
 | 
			
		|||
    migrate_ad_images_dates
 | 
			
		||||
    migrate_ad_banners
 | 
			
		||||
    save_pages
 | 
			
		||||
    menu_enabled_for_to_hash
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # :category_name is optional, depends on the naming of the category model: if no conventional, specify it
 | 
			
		||||
| 
						 | 
				
			
			@ -53,6 +54,10 @@ namespace :new_ui do
 | 
			
		|||
    save_pages
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  task :menu_enabled_for_to_hash => :environment do
 | 
			
		||||
    menu_enabled_for_to_hash
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def migrate_categories(args = nil)
 | 
			
		||||
    if args && args[:app_key] && args[:model_name]
 | 
			
		||||
      migrate_category(args[:app_key], args[:model_name], args[:category_name])
 | 
			
		||||
| 
						 | 
				
			
			@ -244,4 +249,25 @@ namespace :new_ui do
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def menu_enabled_for_to_hash
 | 
			
		||||
    @db ||= Mongoid.database
 | 
			
		||||
    collection_item = @db['items']
 | 
			
		||||
    items = collection_item.find()
 | 
			
		||||
    items.each do |item|
 | 
			
		||||
      item['menu_enabled_for'] = \
 | 
			
		||||
      if item['menu_enabled_for'].present?
 | 
			
		||||
        VALID_LOCALES.inject({}) do |enable, locale|
 | 
			
		||||
          enable[locale] = Array(item['menu_enabled_for']).include?(locale)
 | 
			
		||||
          enable
 | 
			
		||||
        end
 | 
			
		||||
      else
 | 
			
		||||
        VALID_LOCALES.inject({}) do |enable, locale|
 | 
			
		||||
          enable[locale] = false
 | 
			
		||||
          enable
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      collection_item.save(item)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue