menu -> submenu backend
This commit is contained in:
3
back-office/app/models/menu_item.rb
Normal file
3
back-office/app/models/menu_item.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class MenuItem < ActiveRecord::Base
|
||||||
|
has_many :menu_sub_items
|
||||||
|
end
|
||||||
3
back-office/app/models/menu_sub_item.rb
Normal file
3
back-office/app/models/menu_sub_item.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class MenuSubItem < ActiveRecord::Base
|
||||||
|
belongs_to :menu_item
|
||||||
|
end
|
||||||
4
front-api/controllers/menu_item.rb
Normal file
4
front-api/controllers/menu_item.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
get '/menuitem' do
|
||||||
|
# list all menu items
|
||||||
|
MenuItem.eager_load(:menu_sub_items).order("menu_items.ordinal, menu_sub_items.ordinal").to_json(:include => [:menu_sub_items])
|
||||||
|
end
|
||||||
9
front-api/db/migrate/20150324044115_create_menu_items.rb
Normal file
9
front-api/db/migrate/20150324044115_create_menu_items.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CreateMenuItems < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :menu_items do |t|
|
||||||
|
t.string :title
|
||||||
|
t.string :url
|
||||||
|
t.integer :ordinal
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
10
front-api/db/migrate/20150324044314_create_menu_sub_items.rb
Normal file
10
front-api/db/migrate/20150324044314_create_menu_sub_items.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CreateMenuSubItems < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :menu_sub_items do |t|
|
||||||
|
t.string :title
|
||||||
|
t.string :url
|
||||||
|
t.integer :ordinal
|
||||||
|
t.integer :menu_item_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150322044941) do
|
ActiveRecord::Schema.define(version: 20150324044314) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -150,6 +150,19 @@ ActiveRecord::Schema.define(version: 20150322044941) do
|
|||||||
t.string "name"
|
t.string "name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "menu_items", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.string "url"
|
||||||
|
t.integer "ordinal"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "menu_sub_items", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.string "url"
|
||||||
|
t.integer "ordinal"
|
||||||
|
t.integer "menu_item_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "multi_media_descriptions", force: :cascade do |t|
|
create_table "multi_media_descriptions", force: :cascade do |t|
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.integer "item_id"
|
t.integer "item_id"
|
||||||
|
|||||||
3
front-api/models/menu_item.rb
Normal file
3
front-api/models/menu_item.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class MenuItem < ActiveRecord::Base
|
||||||
|
has_many :menu_sub_items
|
||||||
|
end
|
||||||
3
front-api/models/menu_sub_item.rb
Normal file
3
front-api/models/menu_sub_item.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class MenuSubItem < ActiveRecord::Base
|
||||||
|
belongs_to :menu_item
|
||||||
|
end
|
||||||
13
front-ui/app/models/menuItem.js
Normal file
13
front-ui/app/models/menuItem.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
var Backbone = require('backbone');
|
||||||
|
var Globals = require('../globals');
|
||||||
|
var MenuItem = Backbone.Model.extend({
|
||||||
|
urlRoot : Globals.ApiUrl + '/menu_item',
|
||||||
|
defaults: {
|
||||||
|
title: '',
|
||||||
|
url: '',
|
||||||
|
sub_menu_items : []
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = MenuItem;
|
||||||
|
|
||||||
10
front-ui/app/models/menuItemCollection.js
Normal file
10
front-ui/app/models/menuItemCollection.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
var Backbone = require('backbone'),
|
||||||
|
MenuItem = require('./menuItem'),
|
||||||
|
Globals = require('../globals');
|
||||||
|
|
||||||
|
var MenuItemCollection = Backbone.Collection.extend({
|
||||||
|
model: MenuItem,
|
||||||
|
url: Globals.ApiUrl + '/menu_item'
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = MenuItemCollection;
|
||||||
Reference in New Issue
Block a user