parent: @scenario_bay\r
})\r
)\r
+ @listenTo(@root_bay.body, 'http_post', @http_post)\r
+ @listenTo(@root_bay.body, 'save:success', @post_success)\r
+ @listenTo(@root_bay.body, 'save:fail', @post_fail)\r
+ @listenTo(@element_bay, 'add:credit', @add_credit)\r
+ @listenTo(@element_bay, 'pick', @pick)\r
+ @listenTo(@element_bay, 'dialog:open', @open_dialog)\r
+ @listenTo(@element_bay, 'dialog:close', @close_dialog)\r
+ @listenTo(@element_bay, 'destroy', @destroy)\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(tab.render().el)\r
this\r
\r
- add_element: (element) ->\r
- @element_bay.add_element(element)\r
+ init_tabs: () ->\r
+ @element_bay.init_tabs()\r
+ @scenario_bay.init_tabs()\r
+ this.$el.tabs({\r
+ activate: (e, ui) ->\r
+ ui.newPanel.trigger('activate')\r
+ })\r
\r
editor: () ->\r
@parent\r
dom_labels_class: () ->\r
@dom_class() + '-labels'\r
\r
-class Editor.EditorModule.DockModule.RootBay extends Editor.EditorModule.DockModule.SimpleBay\r
- \r
- render: () ->\r
- @body.render()\r
- \r
-class Editor.EditorModule.DockModule.TabModule.RootBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
- \r
-class Editor.EditorModule.DockModule.TabModule.RootBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @form = new Locmare.Bucket.factory(\r
- @root_item().item_name(), \r
- @root_item(), \r
- @mounted(), \r
- 'default', \r
- @dock().editor().operators\r
- )\r
- @bucket = new Editor.EditorModule.DockModule.FormBucket({\r
- parent: this, form: @form\r
- })\r
- \r
- render: () ->\r
- super()\r
- @el.className = @bay().body.dom_class()\r
- this.$el.html(@bucket.render().el)\r
- this\r
- \r
- mounted: () ->\r
- true\r
- \r
- dock: () ->\r
- @parent.dock()\r
- \r
- root_item: () ->\r
- @dock().root_item()\r
- \r
-class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.DockModule.BoardBay\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @elements_tabs = new Editor.EditorModule.DockModule.ElementBay.ElementsTabs({\r
- })\r
- @listenTo(@elements_tabs, 'sorted', @sorted)\r
- \r
- add_element: (element) ->\r
- index = element.get('z') - 1\r
- tab = new Editor.EditorModule.DockModule.ElementBoard({\r
- parent: this, index: index, name: element.item_name(), element: element\r
- })\r
- bb = new Editor.EditorModule.DockModule.TabModule.ElementBoardBody({parent: tab})\r
- @add_tab(\r
- tab, \r
- new Editor.EditorModule.DockModule.TabModule.ElementBoardLabel({parent: tab, name: element.item_name()}), \r
- bb\r
- )\r
- @elements_tabs.add_element_tab(tab)\r
- @elements_tabs.$el.tabs('refresh')\r
- bb.form\r
- \r
- add_new_tab: () ->\r
- tab = new Editor.EditorModule.DockModule.NewElementBoard({\r
- parent: this, index: 0, name: 'new'\r
- })\r
- bb = new Editor.EditorModule.DockModule.TabModule.NewElementBoardBody({parent: tab})\r
- @add_tab(\r
- tab, \r
- new Editor.EditorModule.DockModule.TabModule.NewElementBoardLabel({parent: tab}), \r
- bb\r
- )\r
- @elements_tabs.add_element_tab(tab)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.attr('id', @body.dom_id())\r
- this.$el.append(@elements_tabs.render().el)\r
- @elements_tabs.$el.tabs()\r
- # @add_new_tab()\r
- this\r
- \r
- sorted: () ->\r
- # data-z copy to model\r
- _.each @tabs, (tab) ->\r
- if tab.element # without new_tab\r
- z = parseInt(tab.label.$el.attr('data-z'))\r
- tab.element.set({\r
- z: z\r
- }, {silent: true})\r
- tab.element.trigger('sort')\r
- \r
- panel_body: () ->\r
- @dock().editor().body\r
- \r
-class Editor.EditorModule.DockModule.ElementBay.ElementsTabs extends Backbone.View\r
- tagName: 'div'\r
- className: 'elements_tabs ui-tabs-vertical ui-helper-clearfix'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @inner_elements_tabs = new Editor.EditorModule.DockModule.ElementBay.InnerElementsTabs({\r
- })\r
- @listenTo(@inner_elements_tabs, 'sorted', @sorted)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@inner_elements_tabs.render().$el)\r
- this\r
- \r
- add_element_tab: (tab) ->\r
- @inner_elements_tabs.add_label(tab.label)\r
- this.$el.append(tab.body.render().$el)\r
- \r
- sorted: () ->\r
- # data-z copy to model\r
- @trigger('sorted')\r
- \r
-class Editor.EditorModule.DockModule.ElementBay.InnerElementsTabs extends Backbone.View\r
- tagName: 'ul'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @labels = []\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.addClass('inner-elements-tabs')\r
- _.each @zorderd_labels(), (label) =>\r
- this.$el.append(label.render().$el)\r
- _this = this\r
- this.$el.sortable {\r
- update: (event, ui) ->\r
- z = 1\r
- $('li', $(@)).map ->\r
- $(@).attr('data-z', z)\r
- z++\r
- _this.trigger('sorted')\r
- }\r
- this\r
- \r
- zorderd_labels: () ->\r
- res = []\r
- _.each @labels, (label) =>\r
- res[label.z()] = label\r
- res\r
- \r
- add_label: (label) ->\r
- #z = label.z()\r
- @labels.push(label) # insert array\r
- @render()\r
- label.add_label()\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ElementBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ElementBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
- \r
- render: () ->\r
- @body.render()\r
- \r
-class Editor.EditorModule.DockModule.ElementBoard extends Editor.EditorModule.DockModule.Board\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @element = options.element\r
- \r
- dom_id: () ->\r
- super() + '-' + @element.get('id') # use tab index\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ElementBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
- \r
- render: () ->\r
- super()\r
- this.$el.attr('data-z', @z())\r
- this.$el.removeClass('ui-corner-top')\r
- this.$el.addClass('ui-corner-left')\r
- _this = this\r
- this.$el.mouseover -> \r
- _this.element().trigger('active')\r
- this.$el.mouseout -> \r
- _this.element().trigger('inactive')\r
- this\r
- \r
- z: () ->\r
- @element().get('z')\r
- \r
- add_label: () ->\r
- this.$el.attr('id', @dom_id())\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ElementBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @form = Locmare.Form.factory({\r
- form_name: @element().item_name(), \r
- item: @element(), \r
- mounted: @mounted(), \r
- submit: null, \r
- operators: @dock().editor().operators,\r
- action: '/' + @element().table_name() + '/' + Pettanr.to_s(@element().get('id'))\r
- })\r
- \r
- render: () ->\r
- this.$el.attr('id', @dom_id())\r
- this.$el.html(@form.render().el)\r
- this\r
- \r
- add_element: (element) ->\r
- @form.add_element(element)\r
- \r
- mounted: () ->\r
- true\r
- \r
- element: () ->\r
- @parent.element\r
- \r
-class Editor.EditorModule.DockModule.NewElementBoard extends Editor.EditorModule.DockModule.Board\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @panel = @parent.dock().editor().panel\r
- \r
-class Editor.EditorModule.DockModule.TabModule.NewElementBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
- \r
- render: () ->\r
- super()\r
- this.$el.attr('data-z', @z())\r
- this.$el.removeClass('ui-corner-top')\r
- this.$el.addClass('ui-corner-left')\r
- this\r
- \r
- face: () ->\r
- this.$el.append()\r
- icon = new Pettanr.Image.SymbolImg({attr: {src: '/images/new.gif'}})\r
- linked_elements_tab = new Tag.A({\r
- attr: {href: '#' + @board().body.dom_id() },\r
- content: icon.render().el\r
- })\r
- this.$el.append(linked_elements_tab.render().el)\r
- \r
- z: () ->\r
- 0\r
- \r
- add_label: () ->\r
- this.$el.attr('id', @dom_id())\r
- \r
-class Editor.EditorModule.DockModule.TabModule.NewElementBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- \r
- render: () ->\r
- this.$el.attr('id', @dom_id())\r
- @new_element_pocket = new Editor.EditorModule.DockModule.NewElementPocket({\r
- parent: this\r
- })\r
- this.$el.append(@new_element_pocket.render().el)\r
- this\r
- \r
-class Editor.EditorModule.DockModule.NewElementPocket extends Editor.EditorModule.DockModule.Pocket\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @button_wrapper = new Editor.EditorModule.DockModule.NewElementPocket.ButtonWrapper({\r
- parent: this\r
- })\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@button_wrapper.clear().el)\r
- @add_tabs()\r
- _.each @tabs, (tab) =>\r
- this.$el.append(tab.body.render().el)\r
- @button_wrapper.render()\r
- this.$el.tabs()\r
- this\r
- \r
- add_tabs: () ->\r
- index = 0\r
- _.each @element_models(), (model) =>\r
- tab = new Editor.EditorModule.DockModule.NewElementPocketTab({\r
- parent: this, index: index, name: model.item_name(), model: model\r
- })\r
- bb = new Editor.EditorModule.DockModule.TabModule.NewElementPocketBody({\r
- parent: tab\r
- })\r
- bl = new Editor.EditorModule.DockModule.TabModule.NewElementPocketLabel({\r
- parent: tab\r
- })\r
- @add_tab(tab, bl, bb)\r
- @button_wrapper.add_label(bl)\r
- index++\r
- \r
- panel: () ->\r
- @parent.parent.panel\r
- \r
- element_models: () ->\r
- @panel().my_class().child_models()\r
- \r
-class Editor.EditorModule.DockModule.NewElementPocket.ButtonWrapper extends Backbone.View\r
- tagName: 'div'\r
- className: 'new_elements_tabs ui-tabs-vertical ui-helper-clearfix'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @parent = options.parent\r
- @buttons = new Editor.EditorModule.DockModule.NewElementPocket.Buttons({\r
- parent: this\r
- })\r
- \r
- clear: () ->\r
- this.$el.html('')\r
- this\r
- \r
- render: () ->\r
- this.$el.append(@buttons.render().$el)\r
- this\r
- \r
- add_label: (label) ->\r
- @buttons.add_label(label)\r
- \r
-class Editor.EditorModule.DockModule.NewElementPocket.Buttons extends Backbone.View\r
- tagName: 'ul'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @parent = options.parent\r
- @labels = []\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.addClass('inner-new-elements-tabs')\r
- _.each @labels, (label) =>\r
- this.$el.append(label.render().$el)\r
- this\r
- \r
- add_label: (label) ->\r
- @labels.push(label)\r
- \r
-class Editor.EditorModule.DockModule.TabModule.NewElementPocketLabel extends Editor.EditorModule.DockModule.TabModule.PocketLabel\r
- \r
- render: () ->\r
- super()\r
- this.$el.removeClass('ui-corner-top')\r
- this.$el.addClass('ui-corner-left')\r
- this\r
- \r
- add_label: () ->\r
- this.$el.attr('id', @dom_id())\r
- \r
-class Editor.EditorModule.DockModule.TabModule.NewElementPocketBody extends Editor.EditorModule.DockModule.TabModule.PocketBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- \r
- render: () ->\r
- this.$el.attr('id', @dom_id())\r
- @params = {controller: @model().path_name(), action: 'index'}\r
- @list = Locmare.ListGroup.list(\r
- @model().path_name(), 'index', @operators(), @params\r
- )\r
- @list.open(() =>\r
- pager = Locmare.ListGroupModule.LibModule.Pager.factory(@list.page_status, @params)\r
- f = new Locmare.Filer({\r
- el: '#' + @dom_id(),\r
- item_name: @model().item_name(), \r
- items: @list.items(), \r
- pager: pager, \r
- operators: @operators()\r
- })\r
- )\r
- this\r
- \r
- operators: () ->\r
- @editor().operators\r
- \r
- model: () ->\r
- @pocket_tab().model\r
- \r
- editor: () ->\r
- @dock().parent\r
- \r
-class Editor.EditorModule.DockModule.ScenarioBay extends Editor.EditorModule.DockModule.BoardBay\r
- \r
- initialize: (options) ->\r
- super(options)\r
- i = 0\r
- _.each @elements(), (element) =>\r
- tab = new Editor.EditorModule.DockModule.ScenarioBoard({\r
- parent: this, index: i, name: element.item_name(), element: element\r
- })\r
- @add_tab(\r
- tab, \r
- new Editor.EditorModule.DockModule.TabModule.ScenarioBoardLabel({parent: tab, caption: element.item_name()}), \r
- new Editor.EditorModule.DockModule.TabModule.ScenarioBoardBody({parent: tab})\r
- )\r
- i++\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.attr('id', @body.dom_id())\r
- elements_tabs = new Editor.EditorModule.DockModule.ScenarioBay.ScenarioTabs({\r
- tabs: @tabs\r
- })\r
- this.$el.append(elements_tabs.render().el)\r
- _.each @tabs, (tab) =>\r
- this.$el.append(tab.body.render().el)\r
- elements_tabs.$el.tabs()\r
- this\r
- \r
- elements: () ->\r
- @root_item().scenario_elements()\r
- \r
- class_name: () ->\r
- "tsort-box"\r
- \r
-class Editor.EditorModule.DockModule.ScenarioBay.ScenarioTabs extends Backbone.View\r
- tagName: 'ul'\r
- className: 'tsort'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @tabs = options.tabs\r
- \r
- render: () ->\r
- this.$el.html('')\r
- _.each @tabs, (tab) =>\r
- this.$el.append(tab.label.render().el)\r
- this\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ScenarioBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ScenarioBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- \r
-class Editor.EditorModule.DockModule.ScenarioBoard extends Editor.EditorModule.DockModule.Board\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @element = options.element\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ScenarioBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
- \r
- with_destroy_button: () ->\r
- false\r
- \r
-class Editor.EditorModule.DockModule.TabModule.ScenarioBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @bucket = new Editor.EditorModule.DockModule.ScenarioBucket({\r
- parent: this\r
- })\r
- \r
-class Editor.EditorModule.DockModule.PriorityBay extends Editor.EditorModule.DockModule.BoardBay\r
- \r
- initialize: (options) ->\r
- super(options)\r
- i = 0\r
- _.each @elements(), (element) =>\r
- tab = new Editor.EditorModule.DockModule.PriorityBoard({\r
- parent: this, index: i, name: element.item_name(), element: element\r
- })\r
- @add_tab(\r
- tab, \r
- new Editor.EditorModule.DockModule.TabModule.PriorityBoardLabel({parent: tab, name: element.item_name()}), \r
- new Editor.EditorModule.DockModule.TabModule.PriorityBoardBody({parent: tab})\r
- )\r
- i++\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.attr('id', @body.dom_id())\r
- elements_tabs = new Editor.EditorModule.DockModule.PriorityBay.PriorityTabs({\r
- tabs: @tabs\r
- })\r
- this.$el.append(elements_tabs.render().el)\r
- _.each @tabs, (tab) =>\r
- this.$el.append(tab.body.render().el)\r
- elements_tabs.$el.tabs()\r
- this\r
- \r
- elements: () ->\r
- @root_item().scenario_elements()\r
- \r
- class_name: () ->\r
- "zsort-box"\r
- \r
-class Editor.EditorModule.DockModule.PriorityBay.PriorityTabs extends Backbone.View\r
- tagName: 'ul'\r
- className: 'zsort'\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @tabs = options.tabs\r
- \r
- render: () ->\r
- this.$el.html('')\r
- _.each @tabs, (tab) =>\r
- this.$el.append(tab.label.render().el)\r
- this\r
- \r
-class Editor.EditorModule.DockModule.TabModule.PriorityBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
- \r
-class Editor.EditorModule.DockModule.TabModule.PriorityBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
- \r
-class Editor.EditorModule.DockModule.PriorityBoard extends Editor.EditorModule.DockModule.Board\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @element = options.element\r
- \r
- mounted: () ->\r
+ http_post: (url, root_form) ->\r
+ @trigger('http_post', url, this) # send dock\r
false\r
\r
-class Editor.EditorModule.DockModule.TabModule.PriorityBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
+ post_success: (model, response) ->\r
+ @trigger('save:success', model, response)\r
\r
- with_destroy_button: () ->\r
- false\r
+ post_fail: (model, response) ->\r
+ @trigger('save:fail', response)\r
\r
-class Editor.EditorModule.DockModule.TabModule.PriorityBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
+ add_credit: (element) ->\r
+ @trigger('add:credit', element)\r
\r
- initialize: (options) ->\r
- super(options)\r
- @bucket = new Editor.EditorModule.DockModule.PriorityBucket({\r
- parent: this\r
- })\r
- \r
-# form_manager = Pettanr::Application::manifest.form_managers[self.root_item.form_name]\r
-# form = form_manager.open self.root_item, @dock_body.dock.editor.operators, mounted\r
-# bucket = Bucket.new self,form\r
+ save: () ->\r
+ # merge panel and elements\r
+ attrs = @root_bay.save_data()\r
+ _.extend(attrs, @element_bay.save_data())\r
+ $.extend(true, attrs, @scenario_bay.save_data()) # deep merge by jQuery\r
+ # save json data by panel form\r
+ @root_bay.body.form.save(attrs)\r
\r
-class Editor.EditorModule.DockModule.NewBay extends Editor.EditorModule.DockModule.BoardBay\r
+ pick: (new_item) ->\r
+ @scenario_bay.pick(new_item)\r
+ @trigger('add:element', new_item)\r
\r
-\r
-class Editor.EditorModule.DockModule.TabModule.NewBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
+ open_dialog: (dialog) ->\r
+ @trigger('dialog:open', dialog)\r
\r
-\r
-class Editor.EditorModule.DockModule.TabModule.NewBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
+ close_dialog: (dialog) ->\r
+ @trigger('dialog:close', dialog)\r
\r
- initialize: (options) ->\r
- super(options)\r
- \r
-class Editor.EditorModule.DockModule.NewBoard extends Editor.EditorModule.DockModule.Board\r
- \r
-class Editor.EditorModule.DockModule.TabModule.NewBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
+ destroy: (element) ->\r
+ @trigger('destroy', element)\r
+ @scenario_bay.remove_element(element)\r
\r
-class Editor.EditorModule.DockModule.TabModule.NewBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
- \r
- initialize: (options) ->\r
- super(options)\r
-# form_manager = Pettanr::Application::manifest.form_managers[self.root_item.form_name]\r
-# form = form_manager.open self.root_item, @dock_body.dock.editor.operators, mounted\r
-# bucket = Bucket.new self,form\r
+ quit: () ->\r
+ @root_bay.body.form.quit()\r
\r