diff --git a/.gitignore b/.gitignore index b8a4c577..d27ac727 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,10 @@ uploads/**/* public/panel/**/* public/index.html .DS_Store - +solr/data/**/* *.swp - +*.pid +*.lck public/assets config/application.rb diff --git a/Gemfile b/Gemfile index 3ea8359e..40270a73 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ gem 'mongoid-tree', :require => 'mongoid/tree' gem "mongo_session_store-rails3" gem 'mysql2' gem 'nokogiri' + gem 'radius' gem 'rake' # gem 'remotipart' @@ -84,7 +85,7 @@ group :test, :development do gem "simplecov" gem "delorean" gem "watchr" - gem "spork" + gem "spork" # gem "capybara" # gem 'yard' # gem "bluecloth" diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..4f561da0 --- /dev/null +++ b/Guardfile @@ -0,0 +1,22 @@ +guard 'livereload' do + watch(%r{app/.+\.(erb|haml)}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{public/.+\.(css|js|html)}) + watch(%r{config/locales/.+\.yml}) +end + +guard 'rspec', :version => 2 do + watch(%r{^spec/.+_spec\.rb}) + watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch('spec/spec_helper.rb') { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + watch(%r{^spec/.+_spec\.rb}) + watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] } + watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" } +end \ No newline at end of file diff --git a/app/assets/javascripts/ajax_form.js.erb b/app/assets/javascripts/ajax_form.js.erb index 80abe23f..9f993cd1 100644 --- a/app/assets/javascripts/ajax_form.js.erb +++ b/app/assets/javascripts/ajax_form.js.erb @@ -1,7 +1,7 @@ $('#ajaxForm').ajaxForm({ - beforeSubmit: function(a,f,o) { - o.dataType = 'script'; - }, - success: function(data) { - } + beforeSubmit: function(a,f,o) { + o.dataType = 'script'; + }, + success: function(data) { + } }); \ No newline at end of file diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 18e8e375..902f815d 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -10,7 +10,7 @@ $('.bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - if(confirm("<%= I18n.t('announcement.sure?')%>")){ + if(confirm("<%= I18n.t(:sure?)%>")){ $(this).next('.should_destroy').attr('value', 1); $("tr#" + $(this).prev().attr('value')).hide(); } diff --git a/app/assets/javascripts/inc/ajax_setting.js b/app/assets/javascripts/inc/ajax_setting.js index c23a73bf..d2f183f0 100644 --- a/app/assets/javascripts/inc/ajax_setting.js +++ b/app/assets/javascripts/inc/ajax_setting.js @@ -1,7 +1,7 @@ -jQuery(document).ajaxStart(function(){ - $('').appendTo('body'); -}); +// jQuery(document).ajaxStart(function(){ +// $('').appendTo('body'); +// }); -jQuery(document).ajaxComplete(function(){ - $("#sys_modal").hide().remove(); -}); +// jQuery(document).ajaxComplete(function(){ +// $("#sys_modal").hide().remove(); +// }); diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js index 959f04b2..87973b55 100644 --- a/app/assets/javascripts/inc/modal-preview.js +++ b/app/assets/javascripts/inc/modal-preview.js @@ -3,6 +3,58 @@ // <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> $(document).ready(function() { + // $(".post_preview").click(function(e){ + // $("#main-wrap").after(""); + // e.preventDefault(); + // var form = $(this).parents("form").first() + // //var cont = form["content"].value; + // // $.ajax({ + // // type: 'POST', + // // url: $(this).attr("href")+'?preview=true', + // // data: form.serialize(), + // // dataType: "script", + // // success: function (msg) { + // // $("#"+start_modal_with_id).modal('show'); }, + // // error: function(){ + // // alert("ERROR"); + // // } + // // }); + // url = "/panel/news/back_end/news_bulletins/preview?preview=true" + // // alert(url) + // form.attr("action",url); + // form.submit(); + // //return false; + // }); + $("button.post_preview").click(function(){ + var btn = document.getElementById("button_for_preview"); + var attrs = btn.attributes; + var url = attrs['url']; + // url = url.replace("url=",""); + $("form.nccu_ajax_form").ajaxSubmit({ + beforeSubmit: function(a,f,o){ + $("#main-wrap").after(""); + o.dataType = 'script'; + o.url = url.nodeValue; + o.type = 'post'; + },success: function(msg) { } + + }); + }) + // $("form.nccu_ajax_form").ajaxForm({ + // beforeSubmit: function(a,f,o) { + // // if(clicked_what.hasClass("post_preview")){ + // // $("#main-wrap").after(""); + // // o.dataType = 'script'; + // // o.url = clicked_what.attr("url"); + // // } + // }, + // success: function(data) { + // // if(!clicked_what.hasClass("post_preview")){ + // // window.location = data.redirect_url; + // // } + // } + // }) + $("a.preview_trigger").click(function(){ $("#main-wrap").after(""); $.ajax({ diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 50f3835f..e8bc8405 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -4,33 +4,45 @@ //extended jquery to search fast. $.extend($.expr[':'], { - 'containsi': function (elem, i, match, array) { - return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; - } + 'containsi': function (elem, i, match, array) { + return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; + } }); var interval,sval; $(document).ready(function(){ - $("#user_filter").keyup(function(e){ - if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ - sval = $(this).val(); - $(".checkbox").popover("hide"); - $("div.checkblock").hide(); - clearInterval(interval); - interval = setInterval(waitForSearch,1000); - } - }) + $("#user_filter").keyup(function(e){ + if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); + } + }) }) var waitForSearch = function(){ - if(sval){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").show(); - } - clearInterval(interval); + if(sval){ + var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range + var re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); + if ((re1.test(sval) && (re2.test(sval)))){ + + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:contains("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:contains("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:contains("+sval+")").parent().show(); + } + }else{ + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); + } + } + }else{ + $(".checkbox").popover('hide'); + $("div.checkblock").show(); + } + clearInterval(interval); } \ No newline at end of file diff --git a/app/assets/javascripts/lib/contenteditable.js.erb b/app/assets/javascripts/lib/contenteditable.js.erb index 40c19dd3..9d35acbe 100644 --- a/app/assets/javascripts/lib/contenteditable.js.erb +++ b/app/assets/javascripts/lib/contenteditable.js.erb @@ -40,11 +40,11 @@ $(".nav-tabs").find(".icons-pencil").click(function(){ data: { body: content_holder.html() }, success: function(json) { $(selector).attr("contenteditable",false) - alert("<%= I18n.t('admin.contenteditable.update_done') %>"); + alert("<%= I18n.t('update.success_') %>"); //content_holder.effect('highlight', {'color': '#0f0'}, 3000); }, error: function() { - alert("<%= I18n.t('admin.contenteditable.update_failed') %>"); + alert("<%= I18n.t('update.fail') %>"); //content_holder.effect('highlight', {'color': '#f00'}, 3000); content_holder.html(content); } diff --git a/app/assets/javascripts/news_bulletin_form.js.erb b/app/assets/javascripts/news_bulletin_form.js.erb index 092bbfff..2a96e6be 100644 --- a/app/assets/javascripts/news_bulletin_form.js.erb +++ b/app/assets/javascripts/news_bulletin_form.js.erb @@ -11,7 +11,7 @@ $('.news_bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - if(confirm("<%= I18n.t('news.sure?')%>")){ + if(confirm("<%= I18n.t(:sure?)%>")){ $(this).next('.should_destroy').attr('value', 1); $("tr#" + $(this).prev().attr('value')).hide(); } diff --git a/app/assets/javascripts/orbitTimeline.js b/app/assets/javascripts/orbitTimeline.js index bd2fbb78..bdde5a24 100644 --- a/app/assets/javascripts/orbitTimeline.js +++ b/app/assets/javascripts/orbitTimeline.js @@ -59,7 +59,7 @@ var orbitTimeline = function(dom){ this.constructTimeScale = function(callbackFn){ var mon ="",year="",formname; var scale = $("
"); - $.getJSON("desktop_orbit/gettimelinespan",{"get":"papers"},function(years){ + $.getJSON("/desktop_orbit/gettimelinespan",{"get":"papers"},function(years){ var $ul = $(""); var startyear = years.startyear, endyear = years.endyear,year = years.startyear; $ul.append('
  • '+startyear+'
  • '); @@ -69,7 +69,7 @@ var orbitTimeline = function(dom){ } $("div#orbit div#year_navigation").html($ul); }) - $.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ + $.getJSON("/desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ $.each(papersArray,function(i,pa){ $.each(pa.papers,function(i,paper){ var dt = new Date(paper.created_at); @@ -150,7 +150,7 @@ var orbitTimeline = function(dom){ var scale = $("#scale_wrapper"); t.ajaxload = false; - $.getJSON("desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){ + $.getJSON("/desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){ $.each(papersArray,function(i,pa){ $.each(pa.papers,function(i,paper){ var dt = new Date(paper.created_at); @@ -235,7 +235,7 @@ var orbitTimeline = function(dom){ this.ajaxEventPull = function(){ if(!t.update){ t.update = true; - $.getJSON("desktop_orbit/ajaxeventpull",{"from":t.fromdate},function(){ + $.getJSON("/desktop_orbit/ajaxeventpull",{"from":t.fromdate},function(){ }) } diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 230d6c07..aeb80a24 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1,6 +1,8 @@ // JavaScript Document //harry //Inititialize function will initialize desktop + + $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; @@ -17,19 +19,22 @@ var sortDescending = function(a, b) { }; var orbitDesktop = function(dom){ orbitDesktopAPI.apply(this); - o = this; + // o = this; this.contentHolder = dom; this.themesettings = ""; this.theme = "4f8d3f493b67fcd05f086359"; this.transitionTime = 500; this.currenthtml = "desktop.html"; this.currentface = "home"; - this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":"","appstore":"","orbit":"","books":"","seminar_p":"","research_d":"","research_p":""}; + this.desktopData = {}; this.tp = ""; this.sectionList; + this.data_method; this.initialize = function(){ + var theme = o.theme; var custom = false; + $.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){ if(desktopSettings){ if(desktopSettings.theme!="custom"){ @@ -50,7 +55,16 @@ var orbitDesktop = function(dom){ $("head").find("#dyn_css").remove(); $("head").append(customtheme); } - $(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); + $(document).ready(function(){ + o.loadWallpaper(customwallpaper); + o.bindDesktopEvents(); + o.loadIconCache(); + + $(o.contentHolder).empty().load("desktop",function(){ + o.desktopData["d_desktop"] = ""; + o.initializeDesktop("d_desktop","",false); + }) + }); }) } } @@ -65,105 +79,63 @@ var orbitDesktop = function(dom){ }) }; this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc - $("a#d_app_manager").click(function(){ - var target = $(this).attr("href"); + $(".docklist a").click(function(){ + var target = $(this).attr("id"); + var url = $(this).attr("href"); + o.data_method = $(this).attr("data-method"); if(o.currenthtml!=target){ + if(o.desktopData[o.currentface] == "undefined") + o.desktopData[o.currentface] = ""; o.desktopData[o.currentface] = $(o.contentHolder).html(); $("#content").hide("drop",o.transitionTime,function(){ - o.initializeAppSearch(target); + o.currenthtml = target; + o.currentface = target; + var cache = false; + if(!o.desktopData[o.currentface]){ + $(o.contentHolder).empty().load(url,function(){ + if(typeof o.data_method != "undefined" || o.data_method != "") + window.o[o.data_method](target,url,cache); + }); + }else{ + $(o.contentHolder).html(o.desktopData[o.currentface]); + cache = true; + if(typeof o.data_method != "undefined" || o.data_method != "") + window.o[o.data_method](target,url,cache); + } }); } - }); - $("a#d_desktop").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeDesktop(target); - }); + return false; + }) + $('body').on({ + click: function(){ + if(!$(this).hasClass('active')){ + var sub_data_method = $(this).attr('data-method'); + if(sub_data_method){ + $("#panel_r").load($(this).attr("href"),function(){ + // o.simple_drop_down(); + + // o.tinyscrollbar_ext({ + // main: '.tinycanvas', + // fill: '.s_grid_con' + // }) + window.o[o.data_method][sub_data_method](); + }) + } + $('.s_menu a').removeClass('thmc1 thmtxt active'); + $(this).addClass('thmc1 thmtxt active'); + } + return false; + }, + mouseenter: function(){ + if(!$(this).hasClass('active')){ + $(this).switchClass('admtxt','thmc1 thmtxt',0); + } + }, + mouseleave: function(){ + var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; + $(this).switchClass(t,'admtxt',0); } - }); - $("a#d_sections").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeSectionsManager(target); - }); - } - }); - $("#d_journal_p").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeJournalPapers(target); - }); - } - }); - $("a#d_settings").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeSettings(target); - }); - } - }); - $("a#d_appstore").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeAppstore(target); - }); - } - }); - $("a#d_orbit").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeOrbitTimeline(target); - }); - } - }); - $("a#d_books").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeBooks(target); - }); - } - }); - $("a#d_seminar_p").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeSeminar(target); - }); - } - }); - $("a#d_research_d").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeResearchDomain(target); - }); - } - }); - $("a#d_research_p").click(function(){ - var target = $(this).attr("href"); - if(o.currenthtml!=target){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeResearchProject(target); - }); - } - }); + },'.s_menu a'); $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -188,11 +160,8 @@ var orbitDesktop = function(dom){ }); }; - this.initializeDesktop = function(target){ //this is for initializing main desktops that are sections and tiles + this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles if(!target)target = "desktop"; - o.currenthtml = target; - o.currentface = "home"; - var bindHandlers = function(){ // this function will bind all the handlers in the desktop var groupWrapperWidth = 0; $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);}); @@ -332,14 +301,14 @@ var orbitDesktop = function(dom){ if(j==0)$group.attr("id",tile.group_id); if(tile.data_category == "app") - $li = $('
  • '+tile.title+'

  • '); + $li = $('
  • '+tile.title+'

  • '); else - $li = $('
  • '+tile.title+'

    Loading...
  • '); + $li = $('
  • '+tile.title+'

    Loading...
  • '); $group.find('.col'+colindex).append($li); } } - $("div#desktop div#group_wrapper").append($group); + $("div#desktop div#group_wrapper").append($group); }) bindHandlers(); o.initializeWidgets(); @@ -368,27 +337,23 @@ var orbitDesktop = function(dom){ loadTiles(o.sectionId); }) } - - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadTiles(o.sectionId); - loadSectionList(); - }); + if(cache){ + bindHandlers(); + o.initializeWidgets(); + bindSecondaryHandlers(); + $("div#desktop ul#section_list").empty(); + $.each(o.sectionList,function(i,section){ + var tempstyle=""; + if(section._id==o.sectionId){ + tempstyle = "style='display:none;'"; + $("div#desktop span#section_heading").text(section.name); + } + $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); + }) + bindSecondaryHandlers(); }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - o.initializeWidgets(); - bindSecondaryHandlers(); - $("div#desktop ul#section_list").empty(); - $.each(o.sectionList,function(i,section){ - var tempstyle=""; - if(section._id==o.sectionId){ - tempstyle = "style='display:none;'"; - $("div#desktop span#section_heading").text(section.name); - } - $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); - }) - bindSecondaryHandlers(); + loadTiles(o.sectionId); + loadSectionList(); } }; @@ -396,9 +361,8 @@ var orbitDesktop = function(dom){ $.post("desktop/twitter",function(){}); }; - this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization - o.currenthtml = target; - o.currentface = "apps_manager"; + this.initializeAppSearch = function(target,url,cache){ //this is application search ie is app manager initialization + var searchArray,allApps; var bindHandlers = function(){ // bind handler for app manager page var gn = $('.g_col').length, @@ -474,18 +438,13 @@ var orbitDesktop = function(dom){ bindHandlers(); }) } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadApps(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - } + if(cache) + bindHandlers(); + else + loadApps(); }; - this.initializeSectionsManager = function(target){ // this is init function for section manager - o.currenthtml = target; - o.currentface = "sections"; + this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager + var elementParent,element,slabel; var bindHandlers = function(){ // this is bind handler for section manager page var groupWrapperWidth = 0; @@ -572,50 +531,15 @@ var orbitDesktop = function(dom){ bindHandlers(); }) } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadApps(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); + if(cache) bindHandlers(); - } + else + loadApps(); }; - this.initializeSettings = function(target){ //this is to initialize setting page - o.currenthtml = target; - o.currentface = "settings"; - var bindHandlers = function(){ // this is the bind handler function for setting page - $("div#settings ul#setting_left_nav li a").on({ - click: function(){ - if(!$(this).data("clicked")){ - var tfunc = $(this).attr("href"); - switch(tfunc){ - case "themes": - themes(); - break; - case "sections": - sections(); - break; - case "connection": - connection(); - break; - } - $("div#settings ul#setting_left_nav li a").removeClass('thmc1 thmtxt').data('clicked',null); - $(this).addClass('thmc1 thmtxt').data('clicked',true); - } - }, - mouseenter: function(){ - $(this).removeClass('admtxt').addClass('thmc1 thmtxt'); - }, - mouseleave: function(){ - var t = $(this).data('clicked') ? '' : 'thmc1 thmtxt'; - $(this).removeClass(t).addClass('admtxt'); - } - }); - - } - var sections = function(){ // this load section page in setting page + this.initializeSettings = function(target,url,cache){ //this is to initialize setting page + + this.initializeSettings.sections = function(){ // this load section page in setting page var bindHandlers = function(){ // binding handlers in section page $('.tinycanvas').each(function(){ var h = $(this).parent().height(), @@ -644,17 +568,17 @@ var orbitDesktop = function(dom){ }) }) } - $("div#settings div#panel_r").load("/desktop/settingsections",function(){ + $.getJSON("/desktop/get_desktop_settings",{"get":"sectionnames","desktopid":o.desktopId},function(sectionnames){ $("#desktop_names input").each(function(i){ $(this).val(sectionnames[i]); }) bindHandlers(); }) - }) + } - var themes = function(){ // this opens themes page in setting page + this.initializeSettings.themes = function(){ // this opens themes page in setting page var bindHandlers = function(){ // binding handlers in themes page // live change theme $(".theme_list > .ssl_item").click(function(){ @@ -760,7 +684,7 @@ var orbitDesktop = function(dom){ }); } - $("div#settings div#panel_r").load("/desktop/settingthemes",function(){ + $.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){ $('#st1 .theme_list [id='+theme+']') .addClass("thmc1 active", 300) @@ -770,10 +694,11 @@ var orbitDesktop = function(dom){ bindHandlers(); loadthmc(); }) - }) + } - var connection = function(){ + this.initializeSettings.connection = function(){ + var bindHandlers = function(){ $("#connection_setting ul a").click(function(){ var what = $(this).attr("for"), @@ -846,8 +771,8 @@ var orbitDesktop = function(dom){ } }) } - $("div#settings div#panel_r").load("/desktop/settingconnection",function(){ - $.getJSON("desktop/getaccounts",function(accounts){ + + $.getJSON("/otheraccounts/getaccounts",function(accounts){ $.each(accounts,function(i,account){ $ul = $("#"+account.type+"_connection"); $ul.find("input[type=text]").replaceWith("
    "+account.email+"
    ") @@ -859,64 +784,18 @@ var orbitDesktop = function(dom){ bindHandlers(); }) - }) } - - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); - themes(); - }); }; - this.initializeOrbitTimeline = function(target){ - o.currenthtml = target; - o.currentface = "orbit"; - var bindHandlers = function(){ - var timeline = new orbitTimeline("#timeline"); - timeline.initialize(); - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop_orbit/"+target,function(){ - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - } - }; - this.initializeJournalPapers = function(target){ // this init journal papers - o.currenthtml = target; - o.currentface = "journal_p"; - var bindHandlers = function(){ // bind handler for journal paper - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addpaper': - addpaper(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeOrbitTimeline = function(target,url,cache){ + + var timeline = new orbitTimeline("#timeline"); + timeline.initialize(); - var list = function(){ // to open list part in journal papers page + }; + this.initializeJournalPapers = function(target,url,cache){ // this init journal papers + + this.initializeJournalPapers.list = function(){ // to open list part in journal papers page var journalData; var bindHandlers = function(){ // to bind handlers for list page o.simple_drop_down(); @@ -961,7 +840,7 @@ var orbitDesktop = function(dom){ $("#journal_p div#paper_list a").click(function(){ if($(this).hasClass("icon-check-empty")){ $(this).switchClass("icon-check-empty","icon-check",0); - } else if($(this).hasClass("icon-check")) { + } else if($(this) .hasClass("icon-check")) { $(this).switchClass("icon-check","icon-check-empty",0); } else if($(this).hasClass("icon-star")){ $(this).removeClass("icon-star").addClass("icon-star-empty"); @@ -1048,16 +927,14 @@ var orbitDesktop = function(dom){ bindSecondaryHandlers(); } - $("div#journal_p div#panel_r").load("/desktop/journal_p_list",function(){ - $.getJSON("/desktop_publications/getjournals",function(journals){ - journalData = eval(journals); - journalview(); - bindHandlers(); - }) + $.getJSON("/desktop_publications/getjournals",function(journals){ + journalData = eval(journals); + journalview(); + bindHandlers(); }) } - var addpaper = function(){ // to open add pages in journal papers page + this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page var bindHandlers = function(){ // to bind handlers for add page o.simple_drop_down(); @@ -1066,54 +943,15 @@ var orbitDesktop = function(dom){ fill: '.s_grid_con' }) } - $("div#journal_p div#panel_r").load("/desktop/journal_p_add",function(){ - bindHandlers(); - }) + bindHandlers(); } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); - list(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - list(); - } + }; - this.initializeAppstore = function(target){ - o.currenthtml = target; - o.currentface = "appstore"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'widgets': - widgets(); - break; - case 'onlinestore': - onlinestore(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var widgets = function(){ + this.initializeAppstore = function(target,url,cache){ + + + this.initializeAppstore.widgets = function(){ var bindHandlers = function(){ $("#widget_list a").click(function(){ var sectionid = $(this).attr("for"); @@ -1180,7 +1018,7 @@ var orbitDesktop = function(dom){ fill: '.list_t' }) } - $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){ + $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){ var column = $('
    '), @@ -1230,62 +1068,25 @@ var orbitDesktop = function(dom){ counter++; }) $("#apps_store div#widget_list").append(column); - bindHandlers(); + }) - }) + } - var onlinestore = function(){ + this.initializeAppstore.onlinestore = function(){ var bindHandlers = function(){ } - $("div#apps_store div#panel_r").load("/desktop_appstore/onlinestore",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){ - onlinestore(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - onlinestore(); - bindHandlers(); + } + this.initializeAppstore.onlinestore(); + bindHandlers(); } - this.initializeBooks = function(target){ - o.currenthtml = target; - o.currentface = "books"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addbook': - addbook(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeBooks = function(target,url,cache){ + - var list = function(){ + this.initializeBooks.list = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1295,12 +1096,12 @@ var orbitDesktop = function(dom){ }) } - $("div#books div#panel_r").load("/desktop/books_list",function(){ + bindHandlers(); - }) + } - var addbook = function(){ + this.initializeBooks.addbook = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1310,55 +1111,17 @@ var orbitDesktop = function(dom){ }) } - - $("div#books div#panel_r").load("/desktop/books_add",function(){ - bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); + bindHandlers(); + } - } - this.initializeSeminar = function(target){ - o.currenthtml = target; - o.currentface = "seminar_p"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addseminar': - addseminar(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeBooks.list(); - var list = function(){ + } + this.initializeSeminar = function(target,url,cache){ + + + this.initializeSeminar.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1366,12 +1129,12 @@ var orbitDesktop = function(dom){ }) } - $("div#seminar_p div#panel_r").load("/desktop/seminar_p_list",function(){ + bindHandlers(); - }) + } - var addseminar = function(){ + this.initializeSeminar.addseminar = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1381,53 +1144,15 @@ var orbitDesktop = function(dom){ }) } - $("div#seminar_p div#panel_r").load("/desktop/seminar_p_add",function(){ - bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); bindHandlers(); + } + this.initializeSeminar.list(); + } - this.initializeResearchDomain = function(target){ - o.currenthtml = target; - o.currentface = "research_d"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'add': - add_this(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var list = function(){ + this.initializeResearchDomain = function(target,url,cache){ + + this.initializeResearchDomain.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1435,67 +1160,25 @@ var orbitDesktop = function(dom){ }) } - $("div#research_d div#panel_r").load("/desktop/research_d_list",function(){ + bindHandlers(); - }) + } - var add_this = function(){ + this.initializeResearchDomain.add_this = function(){ var bindHandlers = function(){ - o.simple_drop_down(); - - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) + } - $("div#research_d div#panel_r").load("/desktop/research_d_add",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); - bindHandlers(); + } + this.initializeResearchDomain.list(); + } - this.initializeResearchProject = function(target){ - o.currenthtml = target; - o.currentface = "research_p"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'add': - add_this(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var list = function(){ + this.initializeResearchProject = function(target,url,cache){ + + this.initializeResearchProject.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1503,11 +1186,11 @@ var orbitDesktop = function(dom){ }) } - $("div#research_p div#panel_r").load("/desktop/research_p_list",function(){ + bindHandlers(); - }) + } - var add_this = function(){ + this.initializeResearchProject.add_this = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1517,20 +1200,12 @@ var orbitDesktop = function(dom){ }) } - $("div#research_p div#panel_r").load("/desktop/research_p_add",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); - bindHandlers(); + } + this.initializeResearchProject.list(); + } this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper @@ -1557,16 +1232,16 @@ var orbitDesktop = function(dom){ var widget = $(this); if(widget.attr("data-category")=="widget"){ var widgename = widget.attr("data-content"); - $.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){ - widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb"); + $.getScript(widget.attr("js-link"),function(){ + widget.find("div.appholder").load(widget.attr("data-content")); }); - // $(this).find("div.appholder").append( $('').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css")); + $(this).find("div.appholder").append( '') } }) }; this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db - $.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){ + $.post("/desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){ if(result[0].success=="true") o.notify("Wallpaper saved!!","success",2); else @@ -1697,3 +1372,17 @@ orbitDesktop.prototype.currentUsername = "Harry"; var uselessfunction = function(){ $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"}); } + + + + +orbitDesktop.prototype.initCourses = function(){ + o.notify("Hi there","",""); +} + +orbitDesktop.prototype.something = function(){ + o.notify("something","",""); +} + + + diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index 50bcc232..975485a3 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -14,17 +14,20 @@ function load_tinymce() { theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, + relative_urls : false, // Skin options skin : "o2k7", skin_variant : "silver", - + font_size_style_values : "xx-small,x-small,small,medium,large,x-large,xx-large", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", // external_link_list_url : "js/link_list.js", // external_image_list_url : "js/image_list.js", // media_external_list_url : "js/media_list.js" + content_css: "<%= asset_path('tinymce_orbit.css') %>", + // Style formats style_formats : [ {title : 'Bold text', inline : 'b'}, @@ -40,7 +43,15 @@ function load_tinymce() { template_replace_values : { username : "Some User", staffid : "991234" - } + }, + + // Valide HTML elements + valid_elements : '*[*]', + valid_children : '*[*]', + + // Height & width + height : '400', + width : '100%' }); } function myFileBrowser(field_name, url, type, win) { diff --git a/app/assets/stylesheets/bootstrap.css.erb.backup20120913 b/app/assets/stylesheets/bootstrap.css.erb.backup20120913 index 7cc53a52..e754a970 100644 --- a/app/assets/stylesheets/bootstrap.css.erb.backup20120913 +++ b/app/assets/stylesheets/bootstrap.css.erb.backup20120913 @@ -99,7 +99,7 @@ textarea { body { margin: 0; font-family: /*"Helvetica Neue", */Helvetica, Arial, sans-serif; - font-size: 13px; + font-size: 75%; line-height: 18px; color: #333333; background-color: #ffffff; diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index 436a9b6a..add8774a 100644 --- a/app/assets/stylesheets/member.css +++ b/app/assets/stylesheets/member.css @@ -287,36 +287,42 @@ padding: 0 20px 0 150px !important; margin: 20px 0 0; } -.user-role .user-info { +.role-block .user-info { top: 23px; margin-left: -135px; width: 100px; border-right: none; box-shadow: none; } -.user-role .map-block h4 .gender { +.role-block .map-block h4 .gender { top: -1px; bottom: auto; left: -1px; right: auto; border-radius: 4px 0 0 0; } -.user-role .teacher h4 .gender { +.role-block .teacher h4 .gender { border-color: #186AB6 transparent transparent #186AB6; } -.user-role .student h4 .gender { +.role-block .student h4 .gender { border-color: #F38C08 transparent transparent #F38C08; } -.user-role .staff h4 .gender { +.role-block .staff h4 .gender { border-color: #139E2F transparent transparent #139E2F; } -.user-role .tab-content, .user-role .nav-pills { +.role-block .tab-content, .role-block .nav-pills { float: left; } -.user-role .nav-pills { - margin-left: 10px; +.role-block .nav-pills { + margin-bottom: 0;g } -.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input { +.role-block .nav-pills > li > a { + margin-top: 0; +} +/*.role-block .control-group .inline { + float: +}*/ +.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input, .unRadius input { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; @@ -338,4 +344,8 @@ -webkit-border-radius: 0 3px 3px 0; -moz-border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0; +} +.language-swich .tab-pane { + margin-bottom: 5px; + margin-right: 10px; } \ No newline at end of file diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css index d7d3cda6..53e94c1f 100644 --- a/app/assets/stylesheets/site-map.css +++ b/app/assets/stylesheets/site-map.css @@ -81,37 +81,60 @@ background-color: #5EB92B; font-size: 9px; padding: 0px 10px; - border-radius: 8px; - line-height: 16px; - height: 15px; + border-radius: 11px; + line-height: 20px; + height: 19px; color: #FFF; - width: 38px; + width: 40px; border: none; box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset; - margin-top: 2px; + margin-top: 1px; } /* for mamber role */ - -.user-role .form-horizontal { +.role-block .form-horizontal { padding: 20px 10px 10px; background-color: #FFF; margin-bottom: 0; border-radius: 0 0 4px 4px; } -.user-role .form-horizontal .control-label { +.role-block [class*="type"] { + background-color: #F1F1F1; + padding: 20px 0 10px; + border-radius: 5px; + margin: -25px 0 40px; + /*box-shadow: 0px 1px 3px rgba(100,100,100,.4)*/ +} +.role-block .form-horizontal .control-label { width: 100px; } -.user-role .form-horizontal .controls { +.role-block .form-horizontal .controls { margin-left: 120px; } -.user-role .form-horizontal .controls>.input-append { +.role-block .form-horizontal .controls>.input-append { margin-bottom: 10px; } -.user-role .map-block { +.role-block .form-horizontal legend .onoff { + margin-top: 4px; +} +.role-block .form-horizontal legend .btn-danger { + margin-right: 20px; +} +.role-block .form-horizontal legend>.clear { + margin-right: 150px; + min-width: 350px; +} +.role-block .map-block { min-width: 440px; } -.user-role .map-block legend { +.role-block .map-block .form-actions { + margin: 0; + padding: 10px 20px; +} +.role-block .map-block legend { font-size: 18px; line-height: 25px; } +.role-block .map-block legend .nav { + font-size: 12px; +} diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index 5a8635d3..6a496370 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -476,6 +476,9 @@ .view-mode .btn { margin-bottom: 0; } +.view-mode .btn { + margin-bottom: 0; +} .view-mode i { font-size: 1.2em; line-height: 17px !important; @@ -1464,4 +1467,4 @@ /*21*/ .icons- { background-position: -0px -640px; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/tinymce_orbit.css b/app/assets/stylesheets/tinymce_orbit.css new file mode 100644 index 00000000..3fc87c96 --- /dev/null +++ b/app/assets/stylesheets/tinymce_orbit.css @@ -0,0 +1,4 @@ +body { + font-family: Arial, Helvetica, sans-serif !important; + font-size: 13px !important; +} \ No newline at end of file diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index e3cef303..e4749ade 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -41,7 +41,7 @@ class Admin::AdImagesController < OrbitBackendController @ad_banner = AdBanner.find params[:ad_banner_id] @ad_image = @ad_banner.ad_images.find params[:id] if @ad_image.destroy - flash[:notice] = t('admin.success_destroy_ad_image') + flash[:notice] = t('ad.success_destroy_ad_image') redirect_to admin_ad_banner_path @ad_banner end end diff --git a/app/controllers/admin/asset_categories_controller.rb b/app/controllers/admin/asset_categories_controller.rb index 9ce6bb48..d406543b 100644 --- a/app/controllers/admin/asset_categories_controller.rb +++ b/app/controllers/admin/asset_categories_controller.rb @@ -25,7 +25,7 @@ class Admin::AssetCategoriesController < OrbitBackendController respond_to do |format| if @asset_category.save - format.html { redirect_to(admin_asset_categories_url, :notice => t('announcement.create_asset_category_success')) } + format.html { redirect_to(admin_asset_categories_url, :notice => t('create.success.asset_category')) } format.js else format.html { render :action => "new" } @@ -41,8 +41,8 @@ class Admin::AssetCategoriesController < OrbitBackendController respond_to do |format| if @asset_category.update_attributes(params[:asset_category]) - # format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('asset_category.update_asset_category_success')) } - # format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('asset_category.update_asset_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('create.success')) } + # format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('create.success')) } # format.xml { head :ok } format.js else diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index 6a847a12..77c52ffa 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -44,7 +44,7 @@ class Admin::AssetsController < OrbitBackendController # render :json=>{"url"=>@asset.data.url,"title"=>"xxx","desc"=>"sss"}.to_json render :layout=>false else - flash[:error] = t(:create_fail) + flash[:error] = t('create.fail') @asset_categories = AssetCategory.all @tags = AssetTag.all respond_to do |format| @@ -67,7 +67,7 @@ class Admin::AssetsController < OrbitBackendController format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} } end else - flash[:error] = t(:update_fail) + flash[:error] = t('update.fail') @asset_categories = AssetCategory.all @tags = AssetTag.all respond_to do |format| @@ -105,4 +105,8 @@ class Admin::AssetsController < OrbitBackendController render :layout => false end + def check_permission + true + end + end diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index 5ffa6a06..cec5c5f4 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -1,10 +1,11 @@ class Admin::InfosController < ApplicationController - layout "admin" + layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] - + helper Admin::AttributeValuesViewHelper + def index @attributes = Info.all.entries render :template => 'admin/attributes/index' @@ -32,8 +33,8 @@ class Admin::InfosController < ApplicationController def update @attribute = Info.find(params[:id]) - # binding.pry @attribute.update_attributes(params[:info]) + @attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true} respond_to do |format| format.html { redirect_to :action => :index } format.js { render 'admin/attributes/toggle_enable' } @@ -47,10 +48,10 @@ class Admin::InfosController < ApplicationController end def add_attribute_field - @attribute = Info.find(params[:id]) rescue nil - if !@attribute - @attribute = Info.new - end + attribute = Info.find(params[:info_id]) rescue nil + @attribute_field_counter = attribute.attribute_fields.count + @attribute_field = attribute.attribute_fields.build + @attribute_field.save end protected diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index 1ea40640..e028ab68 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -4,7 +4,6 @@ class Admin::ItemsController < ApplicationController before_filter :authenticate_user! before_filter :find_parent_item - before_filter :find_snippets, :only => :index before_filter :is_admin? before_filter :set_current_item @@ -22,10 +21,4 @@ class Admin::ItemsController < ApplicationController render :nothing => true end - protected - - def find_snippets - @snippets = Snippet.where( { :parent_id => @parent_item.id } ) rescue nil - end - end diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index c233c18f..7c7b4030 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -23,7 +23,7 @@ class Admin::LinksController < ApplicationController @item = Link.new(params[:link]) if @item.save - flash.now[:notice] = t('admin.create_success_link') + flash.now[:notice] = t('create.success.link') respond_to do |format| format.html { redirect_to admin_link_url(@item) @@ -31,7 +31,7 @@ class Admin::LinksController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.create_error_link') + flash.now[:error] = t('create.error.link') render :action => "new" end end @@ -40,7 +40,7 @@ class Admin::LinksController < ApplicationController @item = Link.find(params[:id]) if @item.update_attributes(params[:link]) - flash.now[:notice] = t('admin.update_success_link') + flash.now[:notice] = t('update.success.link') respond_to do |format| format.html { redirect_to admin_link_url(@item) @@ -48,7 +48,7 @@ class Admin::LinksController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.update_error_link') + flash.now[:error] = t('update.error.link') render :action => "edit" end end diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index f747d08b..af529086 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -66,14 +66,14 @@ class Admin::ModuleAppsController < ApplicationController def assign_sub_manager unless @assign_to_user.nil? || @assign_to_user.admin? if @module_app.assign_sub_manager(@assign_to_user,current_user) - flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_ok') + flash[:notice] = t('app_auth.assigning_manager.add_manager_ok') else - flash[:notice] = t('admin.app_auth.assigning_manager.add_sub_manager_fail') + flash[:notice] = t('app_auth.assigning_manager.add_manager_fail') end else - flash[:notice] = t('admin.app_auth.assigning_manager.failed_no_user') + flash[:notice] = t('app_auth.failed_no_user') end - flash[:notice] = t('admin.app_auth.can_not_add_this_user') + flash[:notice] = t('app_auth.can_not_add_this_user') redirect_to :action => "edit" end @@ -81,14 +81,14 @@ class Admin::ModuleAppsController < ApplicationController def assign_manager unless @assign_to_user.nil? || @assign_to_user.admin? if @module_app.assign_manager(@assign_to_user,current_user) - flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_ok') + flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_ok') else - flash[:notice] = t('admin.app_auth.assigning_sub_manager.add_manager_fail') + flash[:notice] = t('app_auth.assigning_sub_manager.add_sub_manager_fail') end else - flash[:notice] = t('admin.app_auth.assigning_sub_manager.failed_no_user') + flash[:notice] = t('app_auth.failed_no_user') end - flash[:notice] = t('admin.app_auth.can_not_add_this_user') + flash[:notice] = t('app_auth.can_not_add_this_user') redirect_to :action => "edit" end @@ -96,9 +96,9 @@ class Admin::ModuleAppsController < ApplicationController def remove_manager @app_manager = AppManager.find(params[:app_manager_id]) if @module_app.remove_manager(@app_manager.user) - flash[:notice] = t('admin.app_auth.delete_manager.success') + flash[:notice] = t('app_auth.delete_manager.success') else - flash[:notice] = t('admin.app_auth.delete_manager.fail') + flash[:notice] = t('app_auth.delete_manager.fail') end redirect_to :action => "edit" end @@ -107,9 +107,9 @@ class Admin::ModuleAppsController < ApplicationController def remove_sub_manager @app_sub_manager = AppManager.find(params[:app_sub_manager_id]) if @module_app.remove_sub_manager(@app_sub_manager.user) - flash[:notice] = t('admin.app_auth.delete_sub_manager.success') + flash[:notice] = t('app_auth.delete_sub_manager.success') else - flash[:notice] = t('admin.app_auth.delete_sub_manager.fail') + flash[:notice] = t('app_auth.delete_sub_manager.fail') end redirect_to :action => "edit" end @@ -123,7 +123,7 @@ class Admin::ModuleAppsController < ApplicationController return end #user is not permited to do that - flash[:notice] = t('admin.app_auth.operation_not_permitted') + flash[:notice] = t('app_auth.operation_not_permitted') render :nothing => true, :status => 403 end @@ -135,7 +135,7 @@ class Admin::ModuleAppsController < ApplicationController return end #user is not permited to do that - flash[:notice] = t('admin.app_auth.operation_not_permitted') + flash[:notice] = t('app_auth.operation_not_permitted') render :nothing => true, :status => 403 end diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index 863af560..2fd7685e 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -25,9 +25,9 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController def update_setting module_app = update_setting_by_params if module_app.save! - flash[:notice] = t("admin.object_auth.update_done") + flash[:notice] = t('update.success_') else - flash[:notice] = t("admin.object_auth.update_failed") + flash[:notice] = t('update.fail') end end diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index ab343360..dab659b4 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -30,7 +30,7 @@ class Admin::ObjectAuthsController < ApplicationController if @object_auth.save redirect_to edit_admin_object_auth_path(@object_auth) else - flash[:error] = t('admin.object.a_object_must_have_only_one_object_auth_profile_for_each_action') + flash[:error] = t('object.a_object_must_have_only_one_object_auth_profile_for_each_action') redirect_to (:back) end end @@ -91,7 +91,8 @@ private def check_if_user_can_do_object_auth unless check_permission(:manager) - render :nothing => true, :status => 403 + #render :nothing => true, :status => 403 + redirect_to '/' end end end \ No newline at end of file diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 3b3f7c24..973f4215 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -7,7 +7,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @ob_auth = ObjectAuth.find params[:object_auth_id] - @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] } @users_array = @ob_auth.privilege_users rescue [] respond_to do |format| @@ -19,9 +19,9 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def update_setting ob_auth = update_setting_by_params if ob_auth.save! - flash[:notice] = t("admin.object_auth.update_done") + flash[:notice] = t('update.success_') else - flash[:notice] = t("admin.object_auth.update_failed") + flash[:notice] = t('update.fail') end end @@ -38,10 +38,12 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController users_to_remove = oa.auth_users - user_sat users_to_new.each do |new_user| + oa.privilege_users << new_user oa.add_user_to_privilege_list(new_user) end users_to_remove.each do |remove_user| + oa.privilege_users.delete_if{|user| user == remove_user} oa.remove_user_from_privilege_list(remove_user) end oa @@ -63,8 +65,26 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def check_if_user_can_do_object_auth unless check_permission(:manager) - render :nothing => true, :status => 403 + redirect_to '/' end end + def check_permission(var) + #app = ModuleApp.first({conditions:{key: params[:module_app_key]}}) + # setup_vars + @module_app.is_manager?(current_user) || current_user.admin? + end + + def setup_vars + if request.env['HTTP_REFERER'].split('/')[4] == "object_auths" + @app_key = params[:app_key] + else + @app_key = request.env['HTTP_REFERER'].split('/')[4] + end + + #@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end") + @app_key.gsub!(/[?].*/,'') + @module_app = ModuleApp.first(conditions: {:key => @app_key} ) + end + end \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 4e4b665d..ed2748c2 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -61,7 +61,7 @@ class Admin::PagePartsController < ApplicationController if @part.update_attributes(params[:page_part]) set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') - flash.now[:notice] = t('admin.update_success_content') + flash.now[:notice] = t('update.success.content') if @part.page.name == 'home' expire_page '/' diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 4a9c5408..cf935a09 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -72,7 +72,7 @@ class Admin::PagesController < ApplicationController end if @item.save - flash.now[:notice] = t('admin.create_success_page') + flash.now[:notice] = t('create.success.page') respond_to do |format| format.html { redirect_to admin_page_url(@item) @@ -80,7 +80,7 @@ class Admin::PagesController < ApplicationController format.js {} end else - flash.now[:error] = t('admin.create_error_page') + flash.now[:error] = t('create.error.page') @apps = ModuleApp.all @designs = Design.all.entries @design = Design.first @@ -99,7 +99,7 @@ class Admin::PagesController < ApplicationController params[:page][:frontend_field_type] = nil if @item.update_attributes(params[:page]) - flash[:notice] = t('admin.update_success_page') + flash[:notice] = t('update.success.page') respond_to do |format| format.html { redirect_to admin_page_url(@item) diff --git a/app/controllers/admin/translations_controller.rb b/app/controllers/admin/translations_controller.rb deleted file mode 100644 index 54da8762..00000000 --- a/app/controllers/admin/translations_controller.rb +++ /dev/null @@ -1,81 +0,0 @@ -class Admin::TranslationsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - - def index - set_variables - end - - def edit - set_variables - end - - # Update either the i18n_variables or the languages - def update - begin - case params[:id] - # Update the i18n_variables - when 'all' - params[:i18n_variables].each do |id, var| - i18n_variable = I18nVariable.find(id) - i18n_variable.update_attributes(var) - end - # Add a language - when 'add' - site = Site.find(session[:site]) - if !site.valid_locales.include?(params[:language]) - site.valid_locales << params[:language] - site.save - I18nVariable.create({:key => params[:language], :document_class => 'language'}) - end - # Enable a language - when 'enable' - site = Site.find(session[:site]) - if !site.in_use_locales.include?(params[:enable_language]) - site.in_use_locales << params[:enable_language] - site.save - end - # Disable a language - when 'disable' - site = Site.find(session[:site]) - if site.in_use_locales.include?(params[:disable_language]) - site.in_use_locales.delete(params[:disable_language]) - site.save - end - # Delete a language and the corresponding i18n_variables - when 'delete' - site = Site.find(session[:site]) - site.in_use_locales.delete(params[:delete_language]) - site.valid_locales.delete(params[:delete_language]) - site.save - I18nVariable.destroy_all(:conditions => {:document_class => 'language', :key => params[:delete_language]}) - end - redirect_to admin_translations_url - rescue - set_variables - render :action => :edit - end - end - - protected - - # Get the i18n_variables and languages - def set_variables - @i18n_variables = I18nVariable.all.entries - @language_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('language') - result - end - @role_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('Role') - result - end - @info_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('UserInfoModel') - result - end - end - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ef44cfc1..e0c8a8f9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -22,7 +22,7 @@ class Admin::UsersController < ApplicationController puts params.to_yaml @user = User.new(params[:user]) if @user.save - flash[:notice] = t('admin.create_success_user') + flash[:notice] = t('create.success.user') redirect_to :action => :index else render :action => :new @@ -42,10 +42,10 @@ class Admin::UsersController < ApplicationController @user.avatar = params[:file] if params[:file] if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - flash.now[:error] = t('admin.cant_revoke_self_admin') + flash.now[:error] = t(:cant_revoke_self_admin) end if !flash[:error] && @user.update_attributes(params[:user]) - flash[:notice] = t('admin.update_success_user') + flash[:notice] = t('update.success.user') redirect_to :action => :index else get_info_and_roles @@ -55,7 +55,7 @@ class Admin::UsersController < ApplicationController def destroy if params[:id].eql?(session['warden.user.user.key'][1].to_s) - flash[:error] = t('admin.cant_delete_self') + flash[:error] = t(:cant_delete_self) else @user = User.find(params[:id]) @user.destroy diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 0609fef0..95be536e 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -33,14 +33,10 @@ class Admin::UsersNewInterfaceController < ApplicationController @student_data = [] @staff_data = [] - - attribute_values = @user.attribute_values.reject{|att_val| - # binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0') - !att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s) - } - + attribute_values = @user.attribute_values attribute_values.each{|att_val| - @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false + binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006' + @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false } @@ -75,7 +71,6 @@ class Admin::UsersNewInterfaceController < ApplicationController end def create - binding.pry puts params.to_yaml # attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' # attribute_values = params[:user].delete(attribute_values_key) @@ -84,8 +79,9 @@ class Admin::UsersNewInterfaceController < ApplicationController # @user.attribute_values.build(value) # } # @user.rebuild_sub_roles_from_attribute_values!(attribute_values) + binding.pry if @user.save - flash[:notice] = t('admin.create_success_user') + flash[:notice] = t('create.success.user') redirect_to :action => :index else @form_index = 0 @@ -119,10 +115,10 @@ class Admin::UsersNewInterfaceController < ApplicationController # @user.avatar = params[:file] if params[:file] # if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - # flash.now[:error] = t('admin.cant_revoke_self_admin') + # flash.now[:error] = t(:cant_revoke_self_admin) # end # if !flash[:error] && @user.update_attributes(params[:user]) - # flash[:notice] = t('admin.update_success_user') + # flash[:notice] = t('update.success.user') # redirect_to :action => :index # else # get_info_and_roles @@ -132,7 +128,7 @@ class Admin::UsersNewInterfaceController < ApplicationController def destroy if params[:id].eql?(session['warden.user.user.key'][1].to_s) - flash[:error] = t('admin.cant_delete_self') + flash[:error] = t(:cant_delete_self) else @user = User.find(params[:id]) @user.destroy diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0588ae5a..e82365e5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base if is_admin? true else - flash[:error] = t("admin.access.denied.not_admin") + flash[:error] = t("access.denied.not_admin") auth_failed_in_backend end end @@ -85,7 +85,7 @@ class ApplicationController < ActionController::Base if is_manager? true else - flash[:error] = t("admin.access.denied.app.not_manager") + flash[:error] = t("access.denied.app.not_manager") auth_failed_in_backend end end @@ -94,7 +94,7 @@ class ApplicationController < ActionController::Base if (@module_app.sub_managing_users.include?(current_or_guest_user) || is_manager?) true else - flash[:error] = t("admin.access.denied.app.not_sub_manager") + flash[:error] = t("access.denied.app.not_sub_manager") auth_failed_in_backend end end @@ -103,13 +103,13 @@ class ApplicationController < ActionController::Base if (@module_app.app_auth.auth_users.include?(current_or_guest_user) || for_app_sub_manager ) true else - flash[:error] = t("admin.access.denied.app.not_authed_user") + flash[:error] = t("access.denied.app.not_authed_user") auth_failed_in_backend end end def check_object_premission(obj,title) - flash[:error] = t("admin.access.denied.object") + flash[:error] = t("access.denied.object") auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_or_guest_user) || is_manager? || is_admin? ) end @@ -129,7 +129,9 @@ class ApplicationController < ActionController::Base object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) module_app = ModuleApp.first(:conditions => {:key => params[:key]}) - @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @item = @object.share_item + #@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + #binding.pry @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 286ec1c4..279694b6 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -27,17 +27,17 @@ class DesktopController< ApplicationController render :layout => false end - def settingthemes + def themes @themes = DesktopTheme.all # raise @themes.inspect render "desktop/settings/themes", :layout => false end - def settingsections + def sections render "desktop/settings/sections", :layout => false end - def settingconnection + def connections render "desktop/settings/connections", :layout => false end @@ -103,11 +103,41 @@ class DesktopController< ApplicationController def getgroups @section = Section.find(params["sectionid"]) @groups = @section.groups - a = Array.new + + gr = Array.new @groups.each do |group| - a << group.tiles + a = Array.new + t = group.tiles + t.each do |tile| + data_content = "" + jsfile = [] + cssfile = "" + shape = "w1 h1" + if tile.data_category == "widget" + widge = DesktopWidget.find(tile.desktop_widget_id.to_s) + # data_content = widge.widget_layout.file + data_content = "/desktop/widget_layout?id="+tile.desktop_widget_id.to_s + jsfile = widge.javascripts.collect{|js| js.file} + cssfile = widge.css_default.file + shape = widge.shape + title = widge.name + else + data_content = tile.data_content + title = tile.title + end + a << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title} + end + gr << a end - render :json =>a.to_json + render :json =>gr.to_json + end + + def widget_layout + widget = DesktopWidget.find(params[:id]) + link = '' + content = widget.widget_layout.body + dhtml = link + content + render :text => dhtml.html_safe end def getsectionlist diff --git a/app/controllers/desktop_widgets_controller.rb b/app/controllers/desktop_widgets_controller.rb new file mode 100644 index 00000000..2605f367 --- /dev/null +++ b/app/controllers/desktop_widgets_controller.rb @@ -0,0 +1,62 @@ +class DesktopWidgetsController < OrbitBackendController + require "net/http" + require "uri" + require 'zip/zip' + + def index + end + + def upload + if !params[:desktop_widget].nil? + temp_file = Tempfile.new("temp_file") + original_file = params[:desktop_widget][:package_file] + #if original_file.content_type == 'application/zip' + temp_file.write(original_file.read.force_encoding('UTF-8')) + temp_file.rewind + filename = File.basename(original_file.original_filename,".zip") + unzip_widget(temp_file, filename) + #else + # flash[:error] = "Upload file should be in zip format" + #end + temp_file.close + end + end + + def unzip_widget(file, zip_name) + Zip::ZipFile.open(file) { |zip_file| + dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json")) + Dir.mktmpdir('f_path') { |dir| + javascripts_entries = [] + images_entries = [] + + zip_file.entries.each do |entry| + case (path = entry.to_s) + when /\A(#{zip_name})\/(default\.css)\z/ + #for default css + dw.build_css_default(:file => get_temp_file(zip_file, dir, entry)) + when /\A(#{zip_name})\/(widget\.html)\z/ #for layout html + dw.build_widget_layout(:file => get_temp_file(zip_file, dir, entry)) + when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js + javascripts_entries << entry + when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img + images_entries << entry + end + end + + ['javascripts', 'images'].each do |type| + eval("#{type}_entries").each do |entry| + eval("dw.#{type}").build(:file => get_temp_file(zip_file, dir, entry)) + end + end + } + dw.save + } + end + def get_temp_file(zip_file, dir, entry) + filename = File.basename(entry.to_s) + temp_file = File.new(dir + '/' + filename, 'w+') + temp_file.write (zip_file.read entry ).force_encoding('UTF-8') + temp_file + end + +end \ No newline at end of file diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 0ac853ed..8f78ea62 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -1,4 +1,4 @@ -class OrbitBackendController< ApplicationController +class OrbitBackendController < ApplicationController #before_filter :setup_vars #before_filter :set_current_user @@ -11,17 +11,15 @@ class OrbitBackendController< ApplicationController layout 'new_admin' def setup_vars - @app_title = request.fullpath.split('/')[2] - @app_title = request.fullpath.split('/')[1] if(@app_title == "back_end") - @app_title.gsub!(/[?].*/,'') - @module_app = ModuleApp.first(conditions: {:key => @app_title} ) + @app_title = controller_path.split('/')[1].singularize + @module_app ||= ModuleApp.first(conditions: {:key => @app_title} ) end private def force_order_for_visitor - setup_vars - set_current_user + setup_vars + set_current_user end diff --git a/app/controllers/otheraccounts_controller.rb b/app/controllers/otheraccounts_controller.rb index 454f108e..d946bd3c 100644 --- a/app/controllers/otheraccounts_controller.rb +++ b/app/controllers/otheraccounts_controller.rb @@ -1,4 +1,4 @@ -class OtheraccountsController< ApplicationController +class Desktop::OtheraccountsController< ApplicationController require 'open-uri' require 'rexml/document' require 'net/http' diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb deleted file mode 100644 index 929c316a..00000000 --- a/app/controllers/sessions_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class SessionsController < Devise::SessionsController - prepend_before_filter :require_no_authentication, :only => [ :new, :create ] - include Devise::Controllers::InternalHelpers - - # POST /resource/sign_in - def create - # login_password = params[:user][:password] - # login_uid = params[:user][:nccu_ldap_uid] - login_password = params[:user][:password] - login_email = params[:user][:email] - result = false - resource = User.first(conditions:{ email: login_email }) - set_flash_message(:notice, :signed_in) if is_navigational_format? - if resource.nil? - logger.error "Can't find user #{login_email}" - flash[:notice] = t('devise.failure.invalid') - render :action => "new" - else - logger.info "=== passed" - resource_name = resource.class.to_s.downcase - sign_in(resource_name, resource) - respond_with resource, :location => redirect_location(resource_name, resource) - end - end - -end diff --git a/app/helpers/admin/ad_banners_helper.rb b/app/helpers/admin/ad_banners_helper.rb index 9c068621..df0d3e73 100644 --- a/app/helpers/admin/ad_banners_helper.rb +++ b/app/helpers/admin/ad_banners_helper.rb @@ -22,8 +22,8 @@ module Admin::AdBannersHelper ad_banner.object_auths.new(title: type ).save oa = ad_banner.get_object_auth_by_title(type) end -# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) - link_to t('admin.ad.cate_auth'),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning" +# link_to t(:category_auth), edit_admin_object_auth_path(oa) + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning" end diff --git a/app/helpers/admin/attribute_values_view_helper.rb b/app/helpers/admin/attribute_values_view_helper.rb new file mode 100644 index 00000000..9a724c96 --- /dev/null +++ b/app/helpers/admin/attribute_values_view_helper.rb @@ -0,0 +1,16 @@ +module Admin::AttributeValuesViewHelper + OPT = [ + ["YYYY / MM / DD hh : mm","format1"], + ["YYYY / MM / DD","format2"], + ["YYYY / MM","format3"], + ["YYYY","format4"] + ] + def show_type_panel(attribute_field,type) + markup = attribute_field.markup + LIST[:markups][markup]["panel"] == type ? type : [type,'hide'].join(" ") + end + + def name_to_id(str) + str.gsub(/\]/,'').gsub(/\[/,"_") + end +end \ No newline at end of file diff --git a/app/helpers/admin/items_helper.rb b/app/helpers/admin/items_helper.rb index 3ac6aed6..2f46b15f 100644 --- a/app/helpers/admin/items_helper.rb +++ b/app/helpers/admin/items_helper.rb @@ -15,9 +15,9 @@ module Admin::ItemsHelper ret << "
    " ret << (link_to node.title, dest, :class => 'js_history') ret << "
    " - ret << (link_to t('admin.edit'), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page') + ret << (link_to t(:edit), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('new.page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('new.link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page') ret << (link_to t(:delete), eval("delete_admin_#{node.class.to_s.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
    " ret << "
    " diff --git a/app/helpers/admin/module_apps_helper.rb b/app/helpers/admin/module_apps_helper.rb index 1bf78ab5..af235976 100644 --- a/app/helpers/admin/module_apps_helper.rb +++ b/app/helpers/admin/module_apps_helper.rb @@ -15,6 +15,6 @@ module Admin::ModuleAppsHelper def get_auth_by(manager_obj) showing_name = manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name - t("admin.user_role.auth.auth_by",:user_display_name => showing_name) + t("auth.auth_by",:user_display_name => showing_name) end end diff --git a/app/helpers/admin/web_component_helper.rb b/app/helpers/admin/web_component_helper.rb new file mode 100644 index 00000000..dda121d1 --- /dev/null +++ b/app/helpers/admin/web_component_helper.rb @@ -0,0 +1,23 @@ +module Admin::WebComponentHelper + include ActionView::Helpers::TagHelper + + def alert_block_tag(title="",context="",*args) + content_tag(:div,:class=>"alert alert-block alert-error fade in") do + a = ActiveSupport::SafeBuffer.new + a << button_tag( 'x',:class=>"close",:data=>{:dismiss=>"alert"}) if (args.first[:close] rescue false) + a << content_tag(:h4,:class=>"alert-heading") do + title + end + a << content_tag(:p) do + context + end + # TODO : 可以提供更多功能 + # a << content_tag(:p) do + # b = link_to("Take this action","",:class=>"btn btn-danger") + # b << link_to("Or do this","",:class=>"btn") + # b + # end + end + + end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 14103d00..76f0f933 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -262,11 +262,15 @@ module ApplicationHelper js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,key), :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") # concat javascript_tag "$('head').append('#{j js}');" end end + def generate_fb_url(object,key) + "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}" + end + def wrap_string_with(str,options={}) line_width = options[:line_width] || 12 wrap_mark = options[:wrap_mark] || "
    " diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index 5e0cf290..9050b9e6 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -9,14 +9,18 @@ module AttributeFieldsHelper include ActionView::Helpers::RenderingHelper def block_helper(user,index,disable = false) - @index = index - @markup_options = markup_options.merge(:disabled=>disable) - @user = user - @attribute_value = @user.get_value_from_field_id(id) - @new_attribute = @attribute_value.nil? - @attribute_value = @attribute_value || @user.attribute_values.build(attribute_field_id: id) - @prefiled_value = @attribute_value.get_values - return instance_eval("render_#{markup}") #rescue "" + unless self.disabled + @index = index + @markup_options = markup_options.merge(:disabled=>disable,:func=>"input_unit") + @user = user + @attribute_value = @user.get_value_from_field_id(id) + @new_attribute = @attribute_value.nil? + @attribute_value = @attribute_value || @user.attribute_values.build( attribute_field_id: id ) + @prefiled_value = @attribute_value.value + @panel_setting = self.get_data + return instance_eval("render_#{markup}") #rescue "" + + end end def lang_tab(str,lang) @@ -24,6 +28,7 @@ module AttributeFieldsHelper end def render_address + #NP control_group_wrapper do |key,value| result = '
    '.html_safe @@ -44,36 +49,55 @@ module AttributeFieldsHelper end def render_checkbox + @prefiled_value ||=[] - markup_value = eval(self.markup_value) rescue {} + # begin + # markup_value = eval(self.markup_value) + # rescue + # markup_value = self.markup_value + # ensure + # markup_value ||= {} + # end + control_group_wrapper do - markup_value.collect do |key,value| - label_tag(key,check_box_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) + a = self[:option_list].collect do |key,value| + label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) end.join rescue "" end end def render_date - control_group_wrapper{date_select(get_field_name_base+"[value]",nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} + #NP + control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} end def render_date_durnation #Need re-write low priority - + end def render_radio_button @prefiled_value ||=[] - markup_value = eval(self.markup_value) rescue {} + # begin + # markup_value = eval(self.markup_value) + # rescue + # markup_value = self.markup_value + # ensure + # markup_value ||= {} + # end control_group_wrapper do - markup_value.collect do |key,value| - label_tag(key,radio_button_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) - end.join rescue "" + self[:option_list].collect do |key,value| + label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) + end.join end end def render_select - markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {} - control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" + + prompt = @panel_setting[:prompt][I18n.locale] rescue nil + @markup_options.merge!(:prompt => prompt) unless prompt.nil? + # markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {} + # check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]} + control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue "" end def render_text_area @@ -81,28 +105,35 @@ module AttributeFieldsHelper if(add_more and value.is_a?(Hash)) values = value values.each_with_index.collect do |value,index| - text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) + place_holder= @panel_setting["placeholder"][key] + text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) end.join.html_safe else value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value - key = can_muti_lang_input ? "[#{key}]" : "[value]" - text_area_tag(get_field_name_base + key, value,@markup_options) + key = can_muti_lang_input ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue '' + text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder)) end end end def render_text_field control_group_wrapper do |key,value| - if(add_more and value.is_a?(Hash)) + if(add_more) values = value - values.each_with_index.collect do |value,index| - - text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options) - end.join.html_safe + result = "" + unless values.nil? + result = values.each_with_index.collect do |value,index| + place_holder= @panel_setting["placeholder"][key] + text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder)) + end.join.html_safe + end + result else - value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value - key = can_muti_lang_input ? "[#{key}]" : "[value]" - text_field_tag(get_field_name_base + key, value,@markup_options) + value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil + key_field = can_muti_lang_input ? "[#{key}]" : "" + place_holder= @panel_setting["placeholder"][key] rescue '' + text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder)) end end end @@ -121,16 +152,18 @@ protected if can_muti_lang_input result << "
    " result << "
    " + VALID_LOCALES.collect do |key| value = @prefiled_value[key.to_s] rescue nil div_class = ["tab-pane" ,"fade"].join(" ") div_class << (key == I18n.locale.to_s ? " active in" : '') result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}") end + result << "
    " result << "" result << "
    " @@ -161,15 +194,13 @@ protected def end_block if @new_attribute - hidden_field_tag(get_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") + hidden_field_tag(get_basic_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}") else - hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}") + hidden_field_tag(get_basic_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}") end end - def get_field_name_base - # "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]" - # binding.pry if @attribute_value[:key] == 'status' + def get_basic_field_name_base if @new_attribute "user[new_attribute_values][#{@index}]" else @@ -177,12 +208,16 @@ protected end end + def get_field_name_base + get_basic_field_name_base + "[value]" + end + def label - label_tag(key,title,:class=>"control-label") + label_tag(key,title,:class=>"control-label",:func => "field_label") end def can_muti_lang_input - locale and LIST[:markups][markup]["muti_lang_input_supprt"] + LIST[:markups][markup]["muti_lang_input_supprt"] #and locale end def can_add_more diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index f73ce2ae..c1894ac2 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -45,7 +45,7 @@ module OrbitBackendHelper end def show_toggle_archive_btn(object) - object.disable ? t("object_disable.change_to_false") : t("object_disable.change_to_true") + object.disable ? t(:disable) : t(:enable) end end \ No newline at end of file diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb index 8756029d..df60bdd2 100644 --- a/app/jobs/nccu_calendar.rb +++ b/app/jobs/nccu_calendar.rb @@ -16,6 +16,6 @@ end # FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) - puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced #{File.join(Rails.root, 'public/static', 'nccu_calendar.xml')}" end end diff --git a/app/models/app_manager.rb b/app/models/app_manager.rb index 0d81a0ec..d2fdc24d 100644 --- a/app/models/app_manager.rb +++ b/app/models/app_manager.rb @@ -2,11 +2,11 @@ class AppManager include Mongoid::Document include Mongoid::Timestamps - belongs_to :user + belongs_to :user,index: true - belongs_to :managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" + belongs_to :managing_app, :polymorphic => true,index: true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" belongs_to :sub_managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :sub_manager,:foreign_key => "sub_user_id" belongs_to :rule_creator,:class_name => 'User' - + end \ No newline at end of file diff --git a/app/models/design/css_default.rb b/app/models/design/css_default.rb index 3ee5a58c..bd4baa8c 100644 --- a/app/models/design/css_default.rb +++ b/app/models/design/css_default.rb @@ -1,5 +1,8 @@ class CssDefault < Stylesheet - belongs_to :design + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :css, polymorphic: true end diff --git a/app/models/design/design.rb b/app/models/design/design.rb index c9d87982..0013082d 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -8,13 +8,13 @@ class Design field :title, :type => String field :version, :type => String - has_one :css_default, :autosave => true, :dependent => :destroy + has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :layout, :autosave => true, :dependent => :destroy has_one :css_reset, :autosave => true, :dependent => :destroy - has_many :images, :autosave => true, :dependent => :destroy - has_many :javascripts, :autosave => true, :dependent => :destroy + has_many :images,as: :imgs, :autosave => true, :dependent => :destroy + has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy has_many :pages - has_many :themes, :autosave => true, :dependent => :destroy + has_many :themes, as: :css, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :images, :allow_destroy => true accepts_nested_attributes_for :javascripts, :allow_destroy => true diff --git a/app/models/design/image.rb b/app/models/design/image.rb index 91c4a733..d1a57d7f 100644 --- a/app/models/design/image.rb +++ b/app/models/design/image.rb @@ -10,7 +10,10 @@ class Image mount_uploader :file, ImageUploader - belongs_to :design + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :imgs, polymorphic: true before_save :set_name diff --git a/app/models/design/javascript.rb b/app/models/design/javascript.rb index 439e3b98..808679d7 100644 --- a/app/models/design/javascript.rb +++ b/app/models/design/javascript.rb @@ -1,3 +1,6 @@ class Javascript < DesignFile - belongs_to :design + # belongs_to :design + # belongs_to :desktop_widget + + belongs_to :js, polymorphic: true end diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index 525e40f3..5e9a5775 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -1,36 +1,40 @@ -class Stylesheet < DesignFile - belongs_to :design - mount_uploader :file_orig, AssetUploader - - def parse_urls - orig_content = content = self.file.read.force_encoding("UTF-8") - # self.remove_file! - # self.remove_file_orig! - names = [] - images = self.design.images - content.scan(/(?<=url)(.*?)(?=\))/){ - css_name = $1.gsub(' ','').gsub('(','') - name = File.basename(css_name).gsub(/[\\\"]/, '') - image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil - image.update_attribute(:in_css, true) if image - file_name = image.file_url rescue nil - names << [css_name, file_name] - } - names.each do |name| - content.gsub!(name[0], name[1]) if name[1] - end - Dir.mktmpdir('f_path') { |dir| - orig_file_name = self.file_identifier - - temp_file = File.new(dir + '/' + orig_file_name, 'w+') - temp_file.write orig_content.force_encoding("UTF-8") - self.file_orig = temp_file - - temp_file = File.new(dir + '/' + orig_file_name, 'w+') - temp_file.write content.force_encoding("UTF-8") - self.file = temp_file - self.save - } - end - -end +class Stylesheet < DesignFile + # belongs_to :design + mount_uploader :file_orig, AssetUploader + + def parse_urls + orig_content = content = self.file.read.force_encoding("UTF-8") + # self.remove_file! + # self.remove_file_orig! + names = {} + images = self.css.images + content.scan(/(?<=url)(.*?)(?=\))/){ + css_name = $1.gsub(' ','').gsub('(','') + unless names.has_key?(css_name) + name = File.basename(css_name).gsub(/[\\\"]/, '') + image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil + if image + image.update_attribute(:in_css, true) + file_name = image.file_url + names.merge!({css_name => file_name}) + end + end + } + names.each_pair do |key, value| + content.gsub!(key, value) + end + Dir.mktmpdir('f_path') { |dir| + orig_file_name = self.file_identifier + + temp_file = File.new(dir + '/' + orig_file_name, 'w+') + temp_file.write orig_content.force_encoding("UTF-8") + self.file_orig = temp_file + + temp_file = File.new(dir + '/' + orig_file_name, 'w+') + temp_file.write content.force_encoding("UTF-8") + self.file = temp_file + self.save + } + end + +end diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index 0935fe12..61a621c0 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -1,6 +1,6 @@ class Theme < Stylesheet - belongs_to :design + belongs_to :css, polymorphic: true protected diff --git a/app/models/desktop.rb b/app/models/desktop/desktop.rb similarity index 70% rename from app/models/desktop.rb rename to app/models/desktop/desktop.rb index e8c1e9c4..6633005f 100644 --- a/app/models/desktop.rb +++ b/app/models/desktop/desktop.rb @@ -2,14 +2,15 @@ class Desktop include Mongoid::Document include Mongoid::Timestamps - field :theme, default: "4f8d3f493b67fcd05f086359" + field :theme, default: "4f8d3f533b67fcd05f08635a" field :customtheme field :wallpaper belongs_to :user + has_and_belongs_to_many :desktop_widgets, :autosave => true has_many :sections, :autosave => true, :dependent => :destroy - has_many :desktop_widgets, :autosave => true, :dependent => :destroy + # has_many :desktop_widgets, :autosave => true, :dependent => :destroy before_create :initialize_section diff --git a/app/models/desktop_theme.rb b/app/models/desktop/desktop_theme.rb similarity index 100% rename from app/models/desktop_theme.rb rename to app/models/desktop/desktop_theme.rb diff --git a/app/models/desktop/desktop_widget.rb b/app/models/desktop/desktop_widget.rb new file mode 100644 index 00000000..feb40aa7 --- /dev/null +++ b/app/models/desktop/desktop_widget.rb @@ -0,0 +1,33 @@ +class DesktopWidget + include Mongoid::Document + include Mongoid::Timestamps + include ParserLayoutWidget + + field :name + field :author + field :shape + field :version, :type => String + + has_one :css_default, as: :css, :autosave => true, :dependent => :destroy + has_one :widget_layout, :autosave => true, :dependent => :destroy + has_many :images, as: :imgs, :autosave => true, :dependent => :destroy + has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy + has_and_belongs_to_many :desktops, :autosave => true + belongs_to :tiles, :autosave => true + + accepts_nested_attributes_for :images, :allow_destroy => true + accepts_nested_attributes_for :javascripts, :allow_destroy => true + + after_save :parse_css_for_images + + # belongs_to :desktop + + + protected + + def parse_css_for_images + self.css_default.parse_urls + parse_widget_for_images(self) + end + +end \ No newline at end of file diff --git a/app/models/desktop/group.rb b/app/models/desktop/group.rb new file mode 100644 index 00000000..2c1992f0 --- /dev/null +++ b/app/models/desktop/group.rb @@ -0,0 +1,18 @@ +class Group + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :section + has_many :tiles, :autosave => true, :dependent => :destroy + before_create :initialize_tile + + def initialize_tile + self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes") + self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word") + widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id} + for i in 0..3 + self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: widgets[i]) + end + end +end + \ No newline at end of file diff --git a/app/models/other_account.rb b/app/models/desktop/other_account.rb similarity index 100% rename from app/models/other_account.rb rename to app/models/desktop/other_account.rb diff --git a/app/models/section.rb b/app/models/desktop/section.rb similarity index 100% rename from app/models/section.rb rename to app/models/desktop/section.rb diff --git a/app/models/tile.rb b/app/models/desktop/tile.rb similarity index 86% rename from app/models/tile.rb rename to app/models/desktop/tile.rb index 70066d1b..91840d8a 100644 --- a/app/models/tile.rb +++ b/app/models/desktop/tile.rb @@ -9,6 +9,6 @@ class Tile field :title belongs_to :group - - + has_one :desktop_widget + end diff --git a/app/models/desktop/widget_layout.rb b/app/models/desktop/widget_layout.rb new file mode 100644 index 00000000..5bf24805 --- /dev/null +++ b/app/models/desktop/widget_layout.rb @@ -0,0 +1,18 @@ +class WidgetLayout < DesignFile + + attr_reader :content + + field :body + + belongs_to :desktop_widget + + + def content + self.file.read.force_encoding("UTF-8") rescue '' + end + + def self.exist_one? + WidgetLayout.count > 0 + end + +end diff --git a/app/models/desktop_widget.rb b/app/models/desktop_widget.rb deleted file mode 100644 index eb0446de..00000000 --- a/app/models/desktop_widget.rb +++ /dev/null @@ -1,13 +0,0 @@ -class DesktopWidget - include Mongoid::Document - include Mongoid::Timestamps - - field :name - field :author - field :shape - field :desktop_id - field :status - field :section - - belongs_to :desktop -end \ No newline at end of file diff --git a/app/models/group.rb b/app/models/group.rb deleted file mode 100644 index 7346ad1e..00000000 --- a/app/models/group.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Group - include Mongoid::Document - include Mongoid::Timestamps - - belongs_to :section - has_many :tiles, :autosave => true, :dependent => :destroy - before_create :initialize_tile - - def initialize_tile - self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table") - self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes") - self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather") - self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock") - self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word") - self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events") - end - -end - \ No newline at end of file diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 88a5ce83..669d82aa 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -48,7 +48,7 @@ class ModuleApp def assign_manager(user,assigner) manager = AppManager.first(conditions: {managing_app_id: self.id,user_id: user.id}) rescue nil if manager.nil? - manager = self.managers.create(:user => user,:rule_creator => assigner) + manager = self.managers.create(:user_id => user.id,:rule_creator_id => (assigner.id rescue nil)) end manager end @@ -56,7 +56,7 @@ class ModuleApp def assign_sub_manager(user,assigner) submanager = AppManager.first(conditions: {sub_managing_app_id: self.id,user_id: user.id}) rescue nil if submanager.nil? && !self.managing_users.include?(user) - submanager = self.sub_managers.create(:user => user,:rule_creator => assigner) + submanager = self.sub_managers.create(:user_id => user.id,:rule_creator_id => (assigner.id rescue nil) ) end submanager end @@ -82,7 +82,7 @@ class ModuleApp protected def set_key - self.key = self.title.underscore if self.title + self.key = self.title.underscore.singularize if self.title end diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index d5cc48de..6c7405ca 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -2,23 +2,28 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true - after_save :check_user_has_app_auth + after_save :check_user_has_can_access_app # > - Something.find_with_auth(query) # > - or Something.find(query).auth + def siblings + ObjectAuth.where({obj_authable_type: obj_authable_type,title: title}) + end + def auth_obj class_obj = eval(self.obj_authable_type) class_obj.find self.obj_authable_id end - def check_user_has_app_auth - sub_managing_users = auth_obj.app_auth.sub_managing_users rescue [] - app_auth = auth_obj.app_auth + def check_user_has_can_access_app + sub_managing_users = auth_obj.module_app.sub_managing_users rescue [] + module_app = auth_obj.module_app self.auth_users.each do |auth_user| if !sub_managing_users.include? auth_user && !auth_user.admin? - app_auth.assign_sub_manager(auth_user,User.current) - app_auth.save! + module_app.assign_sub_manager(auth_user,User.current) + module_app.save end end + end end \ No newline at end of file diff --git a/app/models/preview.rb b/app/models/preview.rb new file mode 100644 index 00000000..9c55fc79 --- /dev/null +++ b/app/models/preview.rb @@ -0,0 +1,110 @@ +class Preview + include Mongoid::Document + include Mongoid::Timestamps + + # field :object_f, :type => Hash + field :object, :type=> Hash + field :preview_at_link + field :expired_at , :type => DateTime + field :link_args, :type => Array + field :object_class_type + + has_many :preview_files, :autosave => true, :dependent => :destroy + has_many :preview_associations, :autosave => true, :dependent => :destroy + # def object=(params) + # save_upload_temp_link(params,"news_bulletin_files_attributes") #unless params[] + # self.object_f = params + # end + + # def object + # return object_f + # end + + # def save_upload_temp_link(params,field_name = "bulletin_files_attributes") + # image = preview_files.build(:file=>params[:image]) + # params[:image] = image.id + + # params[field_name].each_with_index do |item,index| + # bfa = preview_files.build(:file=>params[field_name][index.to_s][:file]) + # params[field_name][index.to_s] = bfa.id + # end unless params[field_name].nil? + # end + + # def dig_in_hash(hash,paths_ary) + # hash.each_pair do |key,in_hash| + # if in_hash.kind_of? Array + # dig_in_array(hash,paths_ary) + # elsif in_hash.kind_of? Hash + # dig_in_hash(hash,paths_ary) + # else + # puts("\n End Node: \t #{paths_ary.join } #{in_hash.class} : #{key}##{in_hash}") + # end + # end + # end + + # def dig_in_array(array,paths_ary) + # array.each do |item| + # if item.kind_of? Array + # dig_in_array(hash,paths_ary) + # elsif item.kind_of? Hash + # dig_in_hash(hash,paths_ary) + # else + # puts("\n End Node: \t #{paths_ary.join } #{item.class} : {item}") + # end + # end + # end + + + # def dig_in_hash_old(hash,paths_ary) + # hash.each_pair do |k,in_hash| + # if (!in_hash.kind_of? Array and !in_hash.kind_of? Hash) + # #p "UploadedFile : #{in_hash.is_a? ActionDispatch::Http::UploadedFile}" + # #in_hash = "no file" if in_hash.is_a? ActionDispatch::Http::UploadedFile + # #in_hash.select{|key,hash| hash.is_a? ActionDispatch::Http::UploadedFile} + # puts("\n End Node:# \n") + # p "#{paths_ary.join } #{in_hash.class} : #{in_hash}" + # #p "UploadedFile(#{in_hash}) : #{in_hash.is_a? ActionDispatch::Http::UploadedFile}" + # else + # if (!in_hash.first.kind_of? Array and !in_hash.first.kind_of? Hash) + # paths_ary << "[#{in_hash.first}]" + # end + # puts("\n Go Down [#{in_hash.first}]\n") + # dig_in_hash(in_hash,paths_ary) + # puts("\n Go Out \n") + # end + # puts "This is last" + # paths_ary.pop + # end + # end + + def get_arg_hash + object.slice(*link_args).inject({}){|la,(k,v)| la[k.to_sym] = v; la} + end + + def get_preview_link + ap = Rails.application.routes.url_helpers + ap.send preview_at_link,({:id=>id,:preview=>true}.merge get_arg_hash) + #func = eval("Rails.application.routes.url_helpers.#{preview_at_link}").send + end + + def get_virtual_object + virtual_object = eval(self.object_class_type).new object + preview_files.each do |file| + if file.file_in_array + eval("virtual_object.#{file.field_name_for_rebuild}.build :file=>file.file") + else + eval("virtual_object.#{file.field_name_for_rebuild} = file.file") + end + end + + preview_associations.each do |local_object| + if local_object.object_in_array + eval("virtual_object.#{local_object.field_name_for_rebuild}.build local_object.object") + else + eval("virtual_object.#{local_object.field_name_for_rebuild} = local_object.object") + end + end + virtual_object + end + +end diff --git a/app/models/preview_association.rb b/app/models/preview_association.rb new file mode 100644 index 00000000..64785b9a --- /dev/null +++ b/app/models/preview_association.rb @@ -0,0 +1,16 @@ +class PreviewAssociation + + include Mongoid::Document + include Mongoid::Timestamps + + field :object, :type=> Hash + field :field_name_for_rebuild + field :object_in_array , :type => Boolean,default: false + + # field :to_save, :type => Boolean + field :should_destroy, :type => Boolean + + belongs_to :preview + # embedded_in :news_bulletin + +end diff --git a/app/models/preview_file.rb b/app/models/preview_file.rb new file mode 100644 index 00000000..d06ddc25 --- /dev/null +++ b/app/models/preview_file.rb @@ -0,0 +1,19 @@ +class PreviewFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :title, localize: true + field :description, localize: true + field :field_name_for_rebuild + field :file_in_array , :type => Boolean,default: false + + # field :to_save, :type => Boolean + field :should_destroy, :type => Boolean + + belongs_to :preview + # embedded_in :news_bulletin + +end diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index faa5876a..c0970863 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -11,6 +11,7 @@ class Attribute has_many :attribute_fields, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :attribute_fields, :allow_destroy => true + def is_built_in? self.built_in end diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 0d9999b3..a94a38a2 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -5,26 +5,43 @@ class AttributeField include ::AttributeFieldsHelper field :key - field :markup - field :markup_value ,:type => Hash + field :markup ,:default=>"text_field" + field :option_list ,:type => Hash,:default => {} field :markup_options,:type => Hash - field :locale, :type => Boolean, :default => true + # field :locale, :type => Boolean, :default => true # field :list_options, :type => Array field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - field :add_more,:type => Boolean, :default => false + field :to_delete,:type=> Boolean,:default => false + field :typeA,:type=> Hash,:default=>{} + field :typeB,:type=> Hash,:default=>{} + field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"} + field :typeD,:type=> Hash,:default=>{} + field :typeE,:type=> Hash,:default=>{} + #field :title, localize: true - field :locale_title, localize: true - field :neutral_title - field :neutral_for + field :title, localize: true + belongs_to :attribute # belongs_to :role has_many :attribute_values,:autosave => true, :dependent => :destroy - + before_save :check_option_list # validates_uniqueness_of :key + def add_more + (get_data["add_more"] == "true" ? true : false) rescue false + end + + def locale + default = true + if get_data["locale"].nil? + return default + else + (get_data["locale"] == "true" ? true : false) rescue default + end + end def self_defined_markup_options? (self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false @@ -36,16 +53,16 @@ class AttributeField end end - def markup_value + def option_list if self_defined_markup_options? #Class need to have corresponding field and value agent # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function method = self.attribute.role.method(self[:key].pluralize+"_for_"+markup) return (method.call rescue {}) - elsif self[:markup_value].nil? || (self[:markup_value].empty?) + elsif self[:option_list].nil? || (self[:option_list].empty?) return {} else - return self[:markup_value] + return self[:option_list] end end @@ -68,36 +85,49 @@ class AttributeField self.attribute.role end - def title_translations - if locale - return locale_title_translations - else - return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}] - end + def panel + panel = LIST[:markups][self[:markup]]["panel"] end - def title_translations=(var) - if locale - self.locale_title_translations = var - end + def get_data + self[panel] end - def title - if locale - return self.locale_title - else - return self.neutral_title - end - end - def title=(var) - # binding.pry - if locale - self.locale_title = var - else - self.neutral_title = var - end - end + # def title_translations + # if locale + # return self.locale_title_translations + # else + # return self[:neutral_title] #Hash[VALID_LOCALES.map{|d| [d,neutral_title]}] + # end + # end + + # def title_translations=(var) + # if locale + # self.locale_title_translations = var + # end + # end + + # def title + # if locale + # return self.locale_title + # else + # return self.neutral_title + # end + # end + + # def check_title + # if locale + # self.locale_title_translations = self[:temp_title] + # else + # self.neutral_title = self[:temp_title] + # end + # self.unset("temp_title") + # end + + # def title=(var) + # self["temp_title"] = var + # end # # Convert the string list_options into an array # def select_list_options=(var) @@ -117,4 +147,9 @@ class AttributeField self.disabled end +protected + def check_option_list + self[:option_list] = self[panel]["option_list"] + end + end diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index a1eb5466..d6500fbf 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -10,11 +10,56 @@ class AttributeValue belongs_to :user before_save :check_key - + before_save :data_proc # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + + def data_proc + # binding.pry + # binding.pry if self.attribute_field.markup == 'radio_button' + # if self.attribute_field + case self.attribute_field.markup + when 'text_field','text_area' + # binding.pry + self[:temp_data].each{|key,val| + self[key] = val + } unless self[:temp_data].nil? + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys rescue {} + end #end of case + else # if not locale + case self.attribute_field.markup + when 'text_field','text_area' + self["val"] = self[:temp_data] + when 'select','date','radio_button' + self["val"] = self[:temp_data] + when 'checkbox' + self["val"] = self[:temp_data].keys rescue {} + end #end of case + # end #of if self.attribute_field + self.unset('temp_data') + end + + def value + + result="" + if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area") + result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}] + else + result = self["val"] + end + result + end + + def value=(value) + #save everything to temp_data waiting for futher process + # binding + self[:temp_data] = value + end + def check_key - binding.pry if attribute_field.nil? self.key = attribute_field.key end @@ -27,45 +72,46 @@ class AttributeValue end def get_value_by_locale(locale) + case self.attribute_field.markup when "text_field" - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value when "select" markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value) - markup_values[self[:value]][locale.to_s] rescue 'NoData' + markup_values[self.value][locale.to_s] rescue 'NoData' when "text_area" - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value when "date" - Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i) rescue nil + Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil when "addr" - self[:value] + self.value when "radio_button" markup_values = eval(self.attribute_field.markup_value) - markup_values[self[:value].first[0]][locale.to_s] - when "checkbox" - markup_values = eval(self.attribute_field.markup_value) - self[:value].keys.collect{|key| markup_values[key][locale.to_s] }.join(",") + markup_values[:value][locale.to_s] + when "checkbox" + markup_values = self.attribute_field.markup_value + self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",") when "date_durnation" - self[:value] + self.value else - self.attribute_field.locale ? self[locale] : self[:value] + self.attribute_field.locale ? self[locale.to_s] : self.value end end - def get_values - unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) - if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] - return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] - else - return get_value_by_locale("") - end - else - if self.attribute_field.markup == "select" - self[:value] - else - self[:value].keys rescue self[:value] - end - end - end + # def get_values + # unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup ) + # if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"] + # return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}] + # else + # return get_value_by_locale("") + # end + # else + # if self.attribute_field.markup == "select" + # self[:value] + # else + # self[:value].keys rescue self[:value] + # end + # end + # end end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 3ae7bf5d..4f645f3b 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -9,10 +9,7 @@ class User field :admin, :type => Boolean, :default => true field :active_role - field :nccu_ldap_uid field :email - # field :cache_dept - # has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :cache_dept,type: Hash field :status_record,type: Hash @@ -38,7 +35,8 @@ class User before_save :save_roles scope :remote_account, where(:nccu_id.ne => nil) - validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") + # validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") + # def new_attribute_values=(vars) # binding.pry # end @@ -179,7 +177,7 @@ class User end def initialize_desktop - self.build_desktop + self.build_desktop(desktop_widget_ids: DesktopWidget.all.collect{|widget| widget.id}) end protected diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index d65a17e0..56160931 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -2,26 +2,26 @@ <% if at_least_module_manager || sub_manager?(ad_banner_tab)%> <%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%>
    - - <%= f.label :ad_fx, t('admin.ad.ab_fx') %> + + <%= f.label :ad_fx, t('ad.ab_fx') %> <%= f.select :ad_fx ,AdBanner::FX_TYPES %> - <%= f.label :transition_sec, t('admin.ad.transition_sec') %> - <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> + <%= f.label :transition_sec, t('ad.transition_sec') %> + <%= f.text_field :transition_sec,:placeholder=>t('ad.sec_place_holder'),:class=> "span3" %> <%= t("ad.trans_unit_sec") %> <%if at_least_module_manager%> - <%= f.label :best_size, t('admin.ad.best_size') %> + <%= f.label :best_size, t('ad.best_size') %> <%= f.text_field :best_size %> Ex: 500px x 300px <% end -%>
    - <%= f.submit t("admin.ad.update_banner"), :class => 'btn' %> + <%= f.submit t("ad.update_banner"), :class => 'btn' %> <%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %>
    <% end -%> <% end -%> -

    <%= t("admin.ad.picture_list")%>

    +

    <%= t("ad.picture_list")%>

    <%if (at_least_module_manager || ad_banner_tab.cur_user_is_sub_manager_of(:edit) )%> <%= content_tag :div ,:class=>'adbanner-action' do%> - <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> + <%= link_to t("ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.id) , :class=>'preview_trigger btn btn-success'%> <% end -%> <% end -%> @@ -30,7 +30,7 @@ <% if at_least_module_manager %> <%= show_ad_banner_permission_link ad_banner_tab%> - <%= link_to t('admin.ad.delete_banner'),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %> + <%= link_to t(:delete),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %> <% end -%> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb index 0b4277a0..15bb75d0 100644 --- a/app/views/admin/ad_banners/_ad_image_update.html.erb +++ b/app/views/admin/ad_banners/_ad_image_update.html.erb @@ -1,7 +1,7 @@
  • <%= image_tag ad_image.file rescue nil%>

    - <%= ad_image.display? ? "[#{t('admin.ad.showing')}]" : "[#{t('admin.ad.not_showing')}]" %> + <%= ad_image.display? ? "[#{t('ad.showing')}]" : "[#{t('ad.not_showing')}]" %> <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>

    <%if at_least_module_manager || sub_manager?(ad_image.ad_banner) %> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 68e0a9c6..dc77bc5f 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -4,33 +4,33 @@