Tiles position saved in db and also change them from section manager

This commit is contained in:
Harry Bomrah committed 2012-04-17 16:33:41 +08:00
1 parent 8d2e5210a1
commit 02c6933d0b
4 files changed
+82 -11

No files matched your search

+42
View File
@@ -48,6 +48,18 @@ class DesktopController< ApplicationController
section.update_attributes(:name => @desktopnewnames[x] )
x = x+1
end
when "appnewsection"
@section = Section.find(params["newsectionid"])
@groups = @section.groups
@app = Tile.find(params["appid"])
@groups.each do |group|
@tiles = group.tiles.where(:data_category.all => ["app"])
if @tiles.length < 12
@app.update_attributes(:group_id => group.id)
break
end
end
end
a = Array.new
a << {"success"=>"true"}
@@ -119,4 +131,34 @@ class DesktopController< ApplicationController
end
render :json=>a.to_json
end
def newpositions
@newpositions = params["newpos"]
@section = Section.find(params["sectionid"])
@groupids = params["groupids"]
@groups = @section.groups
z = 0
@newpositions.each do |grp|
x = 1
grp.each do |tileid|
if x != 1
y = 1
tileid.each do |id|
@tile = Tile.find(id)
@tile.update_attributes({:position => y})
if @tile.group_id != @groupids[z]
@tile.update_attributes({:group_id => @groupids[z]})
end
y = y + 1
end
z = z + 1
end
x = x + 1
end
end
b = Array.new
b << {"success"=>"true"}
render :json=>b.to_json
end
end