big refactor of windows models
This commit is contained in:
@ -123,26 +123,18 @@ function setupColumns(current_user, channel_id) {
|
||||
function createWindowsWithData (data, current_user, channel_id, colName) {
|
||||
|
||||
for (var i in data) {
|
||||
//each array element has a single chart object as an associative array with the type as the key
|
||||
// so I need to iterate over a array with size=1 to get a string with the window type
|
||||
for (var type in data[i]) {
|
||||
var wtype = type;
|
||||
}
|
||||
if (data[i].chart_window) window = data[i].chart_window;
|
||||
if (data[i].plugin_window) window = data[i].plugin_window;
|
||||
if (data[i].portlet_window) window = data[i].portlet_window;
|
||||
|
||||
if (window == "undefined")
|
||||
var window = (data[i].portlet_window) ? data[i].portlet_window : data[i].chart_window;
|
||||
// set the window and window_type
|
||||
var window = data[i].window;
|
||||
var window_type = window.window_type;
|
||||
colId = window.col;
|
||||
title = window.title;
|
||||
|
||||
var content = window.html;
|
||||
if (data[i].chart_window) {
|
||||
var windowId = window.id;
|
||||
$("body").append("<div id='chartConfig"+windowId+"'></div>");
|
||||
}
|
||||
var portlet = addWindow(colName, colId, window.id, wtype, title, content);
|
||||
if (window.window_type === 'chart') {
|
||||
$("body").append("<div id='chartConfig" + window.id + "'></div>");
|
||||
}
|
||||
var portlet = addWindow(colName, colId, window.id, window_type, title, content);
|
||||
portlet.each ( decoratePortlet(current_user) ) ;
|
||||
|
||||
portlet.find( ".ui-toggle" ).click( uiToggleClick );
|
||||
@ -157,10 +149,10 @@ var createWindows = function (current_user, channel_id, colName) {
|
||||
};
|
||||
}
|
||||
|
||||
function addWindow(colName, colId, windowId, wtype, title, content) {
|
||||
function addWindow(colName, colId, windowId, window_type, title, content) {
|
||||
$("#"+colName+"_dialog"+colId).append('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ' +
|
||||
'id="portlet_' + windowId +
|
||||
'"><div class="portlet-header wtype wtype-'+ wtype
|
||||
'"><div class="portlet-header window_type window_type-'+ window_type
|
||||
+ ' ui-widget-header ui-corner-all">' + title +
|
||||
'</div><div class="portlet-content">'+content+'</div>') ;
|
||||
|
||||
@ -215,9 +207,9 @@ var decoratePortlet = function (current_user) {
|
||||
thisObject = $(this);
|
||||
if (current_user == "true") {
|
||||
// Use feature Rollout here - needs to be implemented for this user, and this channel needs to belong to this user.
|
||||
thisObject.find('.wtype').prepend( "<span id='minusBtn' class='ui-toggle ui-icon ui-icon-minusthick'></span>");
|
||||
thisObject.find(".wtype-chart_window").append("<span id='pencilBtn' class='ui-edit ui-icon ui-icon-pencil'></span>");
|
||||
thisObject.find(".wtype").append("<span id='closeBtn' class='ui-close ui-icon ui-icon-close'></span>");
|
||||
thisObject.find('.window_type').prepend( "<span id='minusBtn' class='ui-toggle ui-icon ui-icon-minusthick'></span>");
|
||||
thisObject.find(".window_type-chart").append("<span id='pencilBtn' class='ui-edit ui-icon ui-icon-pencil'></span>");
|
||||
thisObject.find(".window_type").append("<span id='closeBtn' class='ui-close ui-icon ui-icon-close'></span>");
|
||||
thisObject.find(".portlet-header").css("cursor","move");
|
||||
}
|
||||
else {
|
||||
|
@ -6,8 +6,8 @@ class ChartsController < ApplicationController
|
||||
|
||||
window_id = params[:id]
|
||||
logger.debug "Windows ID is #{window_id}"
|
||||
window_detail = @channel.windows.find(window_id).becomes(ChartWindow).window_detail
|
||||
options = window_detail.options unless window_detail.nil?
|
||||
window = @channel.windows.find(window_id)
|
||||
options = window.options unless window.nil?
|
||||
logger.debug "Options for window #{window_id} are " + options.inspect
|
||||
|
||||
render :partial => "charts/config", :locals => {
|
||||
@ -78,9 +78,9 @@ class ChartsController < ApplicationController
|
||||
# save data
|
||||
if params[:newOptions]
|
||||
logger.debug "Updating new style options on window id #{params[:id]} with #{params[:newOptions][:options]}"
|
||||
chart_window = @channel.windows.find(params[:id]).becomes(ChartWindow)
|
||||
chart_window.window_detail.options = params[:newOptions][:options]
|
||||
if !chart_window.save
|
||||
window = @channel.windows.find(params[:id])
|
||||
window.options = params[:newOptions][:options]
|
||||
if !window.save
|
||||
raise "Couldn't save the Chart Window"
|
||||
end
|
||||
end
|
||||
|
@ -37,21 +37,22 @@ class WindowsController < ApplicationController
|
||||
end
|
||||
|
||||
def config_window(window)
|
||||
if window.type == "PluginWindow"
|
||||
pluginName = Plugin.find(window.window_detail.plugin_id).name
|
||||
if window.window_type == "plugin"
|
||||
pluginName = Plugin.find(window.content_id).name
|
||||
window.title = t(window.title, {:name => pluginName})
|
||||
elsif window.type == "ChartWindow"
|
||||
window.title = t(window.title, {:field_number => window.window_detail.field_number})
|
||||
options = window.becomes(ChartWindow).window_detail.options if !window.becomes(ChartWindow).window_detail.nil?
|
||||
elsif window.window_type == "chart"
|
||||
window.title = t(window.title, {:field_number => window.content_id})
|
||||
options = window.options if !window.nil?
|
||||
options ||= ""
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
else
|
||||
window.title = t(window.title)
|
||||
end
|
||||
end
|
||||
|
||||
def html
|
||||
window = Window.find(params[:id])
|
||||
options = window.window_detail.options unless window.window_detail.nil? || window.type!="ChartWindow"
|
||||
options = window.options unless window.nil? || window.window_type != "chart"
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
html = window.html
|
||||
|
||||
@ -60,7 +61,7 @@ class WindowsController < ApplicationController
|
||||
|
||||
def iframe
|
||||
window = Window.find(params[:id])
|
||||
options = window.window_detail.options unless window.window_detail.nil? || window.type!="ChartWindow"
|
||||
options = window.options unless window.nil? || window.window_type != "chart"
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
iframe_html = window.html
|
||||
|
||||
@ -71,29 +72,29 @@ class WindowsController < ApplicationController
|
||||
def index
|
||||
channel = Channel.find(params[:channel_id])
|
||||
|
||||
channel.update_status_portlet false if (channel.windows.select { |w| w.wtype == :status && w.private_flag == false } )
|
||||
channel.update_status_portlet true if (channel.windows.select { |w| w.wtype == :status && w.private_flag == true } )
|
||||
channel.update_video_portlet false if (channel.windows.select { |w| w.wtype == :video && w.private_flag == false } )
|
||||
channel.update_video_portlet true if (channel.windows.select { |w| w.wtype == :video && w.private_flag == true } )
|
||||
channel.update_location_portlet false if (channel.windows.select { |w| w.wtype == :location && w.private_flag == false } )
|
||||
channel.update_location_portlet true if (channel.windows.select { |w| w.wtype == :location && w.private_flag == true } )
|
||||
channel.update_chart_portlets if (channel.windows.select { |w| w.wtype == :chart } )
|
||||
#channel.update_status_portlet false if (channel.windows.select { |w| w.window_type == 'status' && w.private_flag == false } )
|
||||
#channel.update_status_portlet true if (channel.windows.select { |w| w.window_type == 'status' && w.private_flag == true } )
|
||||
#channel.update_video_portlet false if (channel.windows.select { |w| w.window_type == 'video' && w.private_flag == false } )
|
||||
#channel.update_video_portlet true if (channel.windows.select { |w| w.window_type == 'video' && w.private_flag == true } )
|
||||
#channel.update_location_portlet false if (channel.windows.select { |w| w.window_type == 'location' && w.private_flag == false } )
|
||||
#channel.update_location_portlet true if (channel.windows.select { |w| w.window_type == 'location' && w.private_flag == true } )
|
||||
#channel.update_chart_portlets if (channel.windows.select { |w| w.window_type == 'chart' } )
|
||||
windows = channel.public_windows(true).order(:position) unless params[:channel_id].nil?
|
||||
|
||||
if channel.recent_statuses.nil? || channel.recent_statuses.size <= 0
|
||||
@windows = windows.delete_if { |w| w.wtype == "status" }
|
||||
@windows = windows.delete_if { |w| w.window_type == "status" }
|
||||
else
|
||||
@windows = windows
|
||||
end
|
||||
|
||||
@windows.each do |window|
|
||||
|
||||
if window.type == "PluginWindow"
|
||||
pluginName = Plugin.find(window.window_detail.plugin_id).name
|
||||
if window.window_type == "plugin"
|
||||
pluginName = Plugin.find(window.content_id).name
|
||||
window.title = t(window.title, {:name => pluginName})
|
||||
elsif window.type == "ChartWindow"
|
||||
window.title = t(window.title, {:field_number => window.window_detail.field_number})
|
||||
options = window.becomes(ChartWindow).window_detail.options if !window.becomes(ChartWindow).window_detail.nil?
|
||||
elsif window.window_type == "chart"
|
||||
window.title = t(window.title, {:field_number => window.content_id})
|
||||
options = window.options if !window.nil?
|
||||
options ||= ""
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
else
|
||||
@ -104,7 +105,7 @@ class WindowsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @windows.as_json( :include => [:window_detail] ) }
|
||||
format.json { render :json => @windows.as_json }
|
||||
end
|
||||
end
|
||||
|
||||
@ -119,12 +120,12 @@ class WindowsController < ApplicationController
|
||||
else
|
||||
@windows = channel.public_windows(false) unless channel.nil?
|
||||
end
|
||||
@windows.reject! { |window| window.type == "PluginWindow" }
|
||||
@windows.reject! { |window| window.window_type == "plugin" }
|
||||
@windows.each do |window|
|
||||
if window.type == "PluginWindow"
|
||||
elsif window.type == "ChartWindow"
|
||||
window.title = t(window.title, {:field_number => window.window_detail.field_number})
|
||||
options = window.becomes(ChartWindow).window_detail.options unless window.becomes(ChartWindow).window_detail.nil?
|
||||
if window.window_type == "plugin"
|
||||
elsif window.window_type == "chart"
|
||||
window.title = t(window.title, {:field_number => window.content_id})
|
||||
options = window.options unless window.nil?
|
||||
options ||= ""
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
else
|
||||
@ -134,37 +135,36 @@ class WindowsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :partial => "hidden_windows" }
|
||||
# format.json { render :json => @windows.as_json( :include => [:window_detail] ) }
|
||||
format.json { render :json => @windows.as_json }
|
||||
end
|
||||
end
|
||||
|
||||
def private_windows
|
||||
channel = Channel.find(params[:channel_id])
|
||||
|
||||
channel.update_status_portlet false if (channel.windows.select { |w| w.wtype == :status && w.private_flag == false } )
|
||||
channel.update_status_portlet true if (channel.windows.select { |w| w.wtype == :status && w.private_flag == true } )
|
||||
channel.update_video_portlet false if (channel.windows.select { |w| w.wtype == :video && w.private_flag == false } )
|
||||
channel.update_video_portlet true if (channel.windows.select { |w| w.wtype == :video && w.private_flag == true } )
|
||||
channel.update_location_portlet false if (channel.windows.select { |w| w.wtype == :location && w.private_flag == false } )
|
||||
channel.update_location_portlet true if (channel.windows.select { |w| w.wtype == :location && w.private_flag == true } )
|
||||
channel.update_chart_portlets if (channel.windows.select { |w| w.wtype == :chart } )
|
||||
#channel.update_status_portlet false if (channel.windows.select { |w| w.window_type == 'status' && w.private_flag == false } )
|
||||
#channel.update_status_portlet true if (channel.windows.select { |w| w.window_type == 'status' && w.private_flag == true } )
|
||||
#channel.update_video_portlet false if (channel.windows.select { |w| w.window_type == 'video' && w.private_flag == false } )
|
||||
#channel.update_video_portlet true if (channel.windows.select { |w| w.window_type == 'video' && w.private_flag == true } )
|
||||
#channel.update_location_portlet false if (channel.windows.select { |w| w.window_type == 'location' && w.private_flag == false } )
|
||||
#channel.update_location_portlet true if (channel.windows.select { |w| w.window_type == 'location' && w.private_flag == true } )
|
||||
#channel.update_chart_portlets if (channel.windows.select { |w| w.window_type == 'chart' } )
|
||||
|
||||
windows = channel.private_windows(true).order(:position) unless params[:channel_id].nil?
|
||||
|
||||
if channel.recent_statuses.nil? || channel.recent_statuses.size <= 0
|
||||
@windows = windows.delete_if { |w| w.wtype == "status" }
|
||||
@windows = windows.delete_if { |w| w.window_type == "status" }
|
||||
else
|
||||
@windows = windows
|
||||
end
|
||||
|
||||
@windows.each do |window|
|
||||
if window.type == "PluginWindow"
|
||||
windowDetail = window.window_detail
|
||||
pluginName = Plugin.find(windowDetail.plugin_id).name
|
||||
if window.window_type == "plugin"
|
||||
pluginName = Plugin.find(window.content_id).name
|
||||
window.title = t(window.title, {:name => pluginName})
|
||||
elsif window.type == "ChartWindow"
|
||||
window.title = t(window.title, {:field_number => window.window_detail.field_number})
|
||||
options = window.becomes(ChartWindow).window_detail.options unless window.becomes(ChartWindow).window_detail.nil?
|
||||
elsif window.window_type == "chart"
|
||||
window.title = t(window.title, {:field_number => window.content_id})
|
||||
options = window.options unless window.nil?
|
||||
options ||= ""
|
||||
window.html["::OPTIONS::"] = options unless window.html.nil? || window.html.index("::OPTIONS::").nil?
|
||||
else
|
||||
@ -174,7 +174,7 @@ class WindowsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @windows.as_json( :include => [:window_detail] ) }
|
||||
format.json { render :json => @windows.as_json }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -249,26 +249,24 @@ class Channel < ActiveRecord::Base
|
||||
end
|
||||
#remove portlets for fields that don't exist
|
||||
#iterate all chart windows... and look for a matching field
|
||||
chartWindows = windows.where(:wtype => :chart )
|
||||
chartWindows.each do |window|
|
||||
if self.send(window.name).blank?
|
||||
chart_windows = windows.where(:window_type => 'chart' )
|
||||
chart_windows.each do |window|
|
||||
if self.send("field#{window.content_id}").blank?
|
||||
window.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def update_status_portlet isPrivate
|
||||
|
||||
window = windows.where(:wtype => :status, :private_flag => isPrivate )
|
||||
window = windows.where(:window_type => 'status', :private_flag => isPrivate )
|
||||
|
||||
status_html = "<iframe class=\"statusIFrame\" width=\"450\" height=\"260\" frameborder=\"0\" src=\"/channels/#{id}/status/recent\"></iframe>"
|
||||
|
||||
if window.nil? || window[0].nil?
|
||||
|
||||
window = PortletWindow.new
|
||||
window.wtype = :status
|
||||
window = Window.new
|
||||
window.window_type = 'status'
|
||||
window.position = 1
|
||||
window.col = 1
|
||||
window.title = "window_status"
|
||||
@ -279,7 +277,6 @@ class Channel < ActiveRecord::Base
|
||||
|
||||
window.private_flag = isPrivate
|
||||
window.html = status_html
|
||||
window.window_detail = PortletWindowDetail.new if window.window_detail.nil?
|
||||
self.windows.push window
|
||||
|
||||
end
|
||||
@ -289,13 +286,13 @@ class Channel < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_video_portlet isPrivate
|
||||
window = windows.where(:wtype => :video, :private_flag => isPrivate )
|
||||
window = windows.where(:window_type => 'video', :private_flag => isPrivate )
|
||||
if video_fields_valid?
|
||||
youtube_html = "<iframe class=\"youtube-player\" type=\"text/html\" width=\"452\" height=\"260\" src=\"https://www.youtube.com/embed/#{video_id}?wmode=transparent\" frameborder=\"0\" wmode=\"Opaque\" ></iframe>"
|
||||
vimeo_html = "<iframe class=\"vimeo-player\" type=\"text/html\" width=\"452\" height=\"260\" src=\"http://player.vimeo.com/video/#{video_id}\" frameborder=\"0\"></iframe>"
|
||||
if window.nil? || window[0].nil?
|
||||
window = PortletWindow.new
|
||||
window.wtype = :video
|
||||
window = Window.new
|
||||
window.window_type = 'video'
|
||||
window.position = 1
|
||||
window.col = 1
|
||||
window.title = "window_channel_video"
|
||||
@ -305,7 +302,6 @@ class Channel < ActiveRecord::Base
|
||||
window.private_flag = isPrivate
|
||||
window.html = youtube_html if video_type == 'youtube'
|
||||
window.html = vimeo_html if video_type == 'vimeo'
|
||||
window.window_detail = PortletWindowDetail.new if window.window_detail.nil?
|
||||
self.windows.push window
|
||||
else
|
||||
unless window[0].nil?
|
||||
@ -315,13 +311,13 @@ class Channel < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def update_location_portlet isPrivate
|
||||
window = windows.where(:wtype => :location, :private_flag => isPrivate )
|
||||
window = windows.where(:window_type => 'location', :private_flag => isPrivate )
|
||||
if !latitude.nil? && !longitude.nil?
|
||||
maps_html = "<iframe width=\"450\" height=\"260\" frameborder=\"0\" scrolling=\"no\" " +
|
||||
"src=\"/channels/#{id}/maps/channel_show?width=450&height=260\"></iframe>"
|
||||
if window.nil? || window[0].nil?
|
||||
window = PortletWindow.new
|
||||
window.wtype = :location
|
||||
window = Window.new
|
||||
window.window_type = 'location'
|
||||
window.position = 0
|
||||
window.col = 1
|
||||
window.title = "window_map"
|
||||
@ -330,7 +326,6 @@ class Channel < ActiveRecord::Base
|
||||
end
|
||||
window.private_flag = isPrivate
|
||||
window.html = maps_html
|
||||
window.window_detail = PortletWindowDetail.new if window.window_detail.nil?
|
||||
|
||||
self.windows.push window
|
||||
|
||||
@ -487,27 +482,26 @@ class Channel < ActiveRecord::Base
|
||||
|
||||
def set_ranking
|
||||
update_attribute(:ranking, calc_ranking) unless ranking == calc_ranking
|
||||
|
||||
end
|
||||
|
||||
def update_chart_portlet (field, isPrivate)
|
||||
|
||||
chartWindows = windows.where(:type => "ChartWindow", :name => "field#{field.last.to_s}", :private_flag => isPrivate )
|
||||
chartWindows = windows.where(:window_type => "chart", :name => "field#{field.last.to_s}", :private_flag => isPrivate )
|
||||
if chartWindows.nil? || chartWindows[0].nil?
|
||||
window = ChartWindow.new
|
||||
window.wtype = :chart
|
||||
window = Window.new
|
||||
window.window_type = 'chart'
|
||||
window.position = 0
|
||||
window.col = 0
|
||||
window.title = "window_field_chart"
|
||||
window.name = field.to_s
|
||||
window.window_detail = ChartWindowDetail.new
|
||||
window.window_detail.options = "&results=60&dynamic=true"
|
||||
window.options = "&results=60&dynamic=true"
|
||||
else
|
||||
window = chartWindows[0]
|
||||
# If there are options, use them.. if options are not available, then assign defaults
|
||||
window.window_detail.options ||= "&results=60&dynamic=true"
|
||||
window.options ||= "&results=60&dynamic=true"
|
||||
end
|
||||
|
||||
window.window_detail.field_number = field.last
|
||||
window.content_id = field.last
|
||||
window.private_flag = isPrivate
|
||||
windows.push window
|
||||
window.html ="<iframe id=\"iframe#{window.id}\" width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"/channels/#{id}/charts/#{field.last.to_s}?width=450&height=260::OPTIONS::\" ></iframe>"
|
||||
|
@ -1,22 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: windows
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# channel_id :integer
|
||||
# position :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# html :text
|
||||
# col :integer
|
||||
# title :string(255)
|
||||
# wtype :string(255)
|
||||
# name :string(255)
|
||||
# type :string(255)
|
||||
# private_flag :boolean default(FALSE)
|
||||
# show_flag :boolean default(TRUE)
|
||||
#
|
||||
|
||||
class ChartWindow < Window
|
||||
relate_to_details
|
||||
end
|
@ -1,14 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: chart_window_details
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# chart_window_id :integer
|
||||
# field_number :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# options :string(255)
|
||||
#
|
||||
|
||||
class ChartWindowDetail < ActiveRecord::Base
|
||||
end
|
@ -15,12 +15,11 @@
|
||||
|
||||
class Plugin < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
has_many :plugin_window_details
|
||||
has_many :windows, :through => :plugin_window_details, :source => :plugin_window
|
||||
has_many :windows, -> { where window_type: 'plugin' }, :foreign_key => :content_id, :source => :window
|
||||
before_destroy { |record| record.windows.each { |window| window.delete } }
|
||||
|
||||
def destroy_window
|
||||
window_id = PluginWindowDetail.find_by_plugin_id(self.id).plugin_window_id
|
||||
window_id = Window.where(content_id: self.id, window_type: 'plugin').first.id
|
||||
Window.delete(window_id)
|
||||
end
|
||||
|
||||
@ -88,12 +87,11 @@ class Plugin < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def make_windows(channel_id, api_domain)
|
||||
pluginWindows = []
|
||||
#create all the windows as appropriate
|
||||
#Private plugins have one window..
|
||||
#Public plugins have a private/private windows, private/public window and a public window
|
||||
if !has_public_windows(channel_id) && self.public?
|
||||
windows << PluginWindow.new_from(self, channel_id, :public, api_domain)
|
||||
windows << Window.new_from(self, channel_id, :public, api_domain)
|
||||
else
|
||||
update_windows(channel_id)
|
||||
end
|
||||
@ -132,3 +130,4 @@ class Plugin < ActiveRecord::Base
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: windows
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# channel_id :integer
|
||||
# position :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# html :text
|
||||
# col :integer
|
||||
# title :string(255)
|
||||
# wtype :string(255)
|
||||
# name :string(255)
|
||||
# type :string(255)
|
||||
# private_flag :boolean default(FALSE)
|
||||
# show_flag :boolean default(TRUE)
|
||||
#
|
||||
|
||||
class PluginWindow < Window
|
||||
relate_to_details
|
||||
end
|
||||
|
@ -1,16 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: plugin_window_details
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# plugin_id :integer
|
||||
# plugin_window_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
#
|
||||
|
||||
class PluginWindowDetail < ActiveRecord::Base
|
||||
belongs_to :plugin_window
|
||||
belongs_to :plugin
|
||||
|
||||
end
|
@ -1,22 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: windows
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# channel_id :integer
|
||||
# position :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# html :text
|
||||
# col :integer
|
||||
# title :string(255)
|
||||
# wtype :string(255)
|
||||
# name :string(255)
|
||||
# type :string(255)
|
||||
# private_flag :boolean default(FALSE)
|
||||
# show_flag :boolean default(TRUE)
|
||||
#
|
||||
|
||||
class PortletWindow < Window
|
||||
relate_to_details
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: portlet_window_details
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# portlet_window_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
#
|
||||
|
||||
class PortletWindowDetail < ActiveRecord::Base
|
||||
end
|
@ -10,32 +10,28 @@
|
||||
# html :text
|
||||
# col :integer
|
||||
# title :string(255)
|
||||
# wtype :string(255)
|
||||
# window_type :string(255)
|
||||
# name :string(255)
|
||||
# type :string(255)
|
||||
# private_flag :boolean default(FALSE)
|
||||
# show_flag :boolean default(TRUE)
|
||||
# content_id :integer
|
||||
# options :text
|
||||
#
|
||||
|
||||
# content_id refers to plugin_id, field_number, etc depending on the window type
|
||||
# valid values for window_type: status, location, chart, plugin, video
|
||||
class Window < ActiveRecord::Base
|
||||
belongs_to :channel
|
||||
|
||||
self.include_root_in_json = true
|
||||
|
||||
def self.relate_to_details
|
||||
class_eval <<-EOF
|
||||
has_one :window_detail, :class_name => "#{self.name}Detail"
|
||||
accepts_nested_attributes_for :window_detail
|
||||
default_scope { includes(:window_detail) }
|
||||
EOF
|
||||
end
|
||||
def private?
|
||||
return private_flag
|
||||
end
|
||||
|
||||
def self.new_from( plugin, channel_id, privacy_flag, api_domain )
|
||||
window = PluginWindow.new
|
||||
window.wtype = :plugin
|
||||
window = Window.new
|
||||
window.window_type = 'plugin'
|
||||
window.position = 0
|
||||
window.col = 0
|
||||
window.title = "window_plugin"
|
||||
@ -45,6 +41,7 @@ class Window < ActiveRecord::Base
|
||||
window.html ="<iframe width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"/plugins/#{plugin.id}\" ></iframe>"
|
||||
window.show_flag = false
|
||||
window if window.save
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -26,16 +26,15 @@
|
||||
$.update("/channels/" + channelId + "/windows/"+ windowId + "/display" , data,
|
||||
function(response) {
|
||||
|
||||
var window = response.plugin_window;
|
||||
var window = response.window;
|
||||
var window_type = window.window_type;
|
||||
var colId = window.col;
|
||||
|
||||
var colName = (window.private_flag == true) ? "private" : "public";
|
||||
|
||||
addPlugin.hide();
|
||||
for (var type in response) {
|
||||
var wtype = type;
|
||||
}
|
||||
var portlet = addWindow(colName,colId, window.id, wtype, window.title, window.html );
|
||||
|
||||
var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html );
|
||||
//for each portlet
|
||||
|
||||
portlet.each ( decoratePortlet("true") );
|
||||
@ -56,14 +55,12 @@
|
||||
var windowId =ids[2];
|
||||
$.update("/channels/" + channelId +"/windows/"+ windowId + "/display" ,
|
||||
function(response) {
|
||||
var window = (response.portlet_window) ? response.portlet_window : response.chart_window;
|
||||
var window = response.window;
|
||||
var window_type = window.window_type;
|
||||
var colId = window.col;
|
||||
var colName = (window.private_flag == true) ? "private" : "public";
|
||||
addPortlet.hide();
|
||||
for (var type in response) {
|
||||
var wtype = type;
|
||||
}
|
||||
var portlet = addWindow(colName,colId, window.id, wtype, window.title, window.html );
|
||||
var portlet = addWindow(colName,colId, window.id, window_type, window.title, window.html );
|
||||
//for each portlet
|
||||
|
||||
portlet.each ( decoratePortlet("true") );
|
||||
|
Reference in New Issue
Block a user