show: () ->\r
console.log(@params)\r
id = @params['id']\r
- @item = new Pettanr.FolderWatch({id: id})\r
- _this = this\r
- @item.fetch({}).done () ->\r
- if _this.item.is_remote()\r
- c = _this.item.get('controller_name')\r
- a = if Pettanr.is_blank(_this.item.get('action_name'))\r
- 'index'\r
+ if @params['format'] == 'prof'\r
+ @set_show()\r
+ @show_prof()\r
+ else\r
+ @item = new Pettanr.FolderWatch({id: id})\r
+ _this = this\r
+ @item.fetch({}).done () ->\r
+ if _this.item.is_remote()\r
+ c = _this.item.get('controller_name')\r
+ a = if Pettanr.is_blank(_this.item.get('action_name'))\r
+ 'index'\r
+ else\r
+ _this.item.get('action_name')\r
+ window.router['c_i'](c, a, '') # call action event in router for redirect\r
else\r
- _this.item.get('action_name')\r
- window.router['c_i'](c, a, '') # call action event in router for redirect\r
- else\r
- _this.children_html()\r
+ _this.children_html()\r
\r
count: () ->\r
\r
by_panel: () ->\r
@filer_list()\r
\r
+ show_html: () -> \r
+ \r
show: (params) ->\r
- console.log(params)\r
- id = params['id']\r
- item = new Pettanr.Scroll({id: id})\r
- _this = this\r
- item.fetch({}).done () ->\r
- alert(item)\r
+ @set_show()\r
+ switch @params['format']\r
+ when 'prof'\r
+ @show_prof()\r
+ when 'html'\r
+ @show_html()\r
\r
count: (params) ->\r
\r
\r
list_options: (id) ->\r
params = {controller: @table_name, action: @list_name, id: id, page: 1, page_size: 3}\r
- {model: @model(), params: params}\r
+ cm = Manifest.manifest().controllers[@table_name]\r
+ am = cm.actions[@list_name]\r
+ {model: @model(), action: am, params: params}\r
\r
model: () ->\r
Manifest.item_name_to_model @model_name\r
@list_name = n[1]\r
else\r
ManifestBase.alert_undefined_message 'list', @module_message\r
+ @table_name = @model().table_name()\r
\r
list_options: (id) ->\r
- params = {controller: @model().table_name(), action: @list_name, id: id, page: 1, page_size: 3}\r
- {model: @model(), params: params}\r
+ params = {controller: @table_name, action: @list_name, id: id, page: 1, page_size: 3}\r
+ cm = Manifest.manifest().controllers[@table_name]\r
+ am = cm.actions[@list_name]\r
+ {model: @model(), action: am, params: params}\r
\r
model: () ->\r
Manifest.item_name_to_model @model_name\r
\r
initialize: (options) ->\r
@body = options.body\r
- @collection = []\r
+ @file_items = []\r
_this = this\r
c = @filer().collection\r
c.fetch().done ->\r
- _this.filer().items = c.models\r
- _this.collection = _.map c.models, (item) ->\r
- c = _this.file_item_class()\r
- new c({'file_body': _this, 'item': item})\r
+ items = if c['singular'] # type of model?\r
+ [c]\r
+ else\r
+ c.models\r
+ _this.file_items = _.map items, (item) ->\r
+ fi = _this.file_item_class()\r
+ new fi({'file_body': _this, 'item': item})\r
_this.render()\r
\r
render: () ->\r
_this = this\r
this.$el.html('')\r
- _.each @collection, (file_item) ->\r
+ _.each @file_items, (file_item) ->\r
_this.$el.append(file_item.render().el)\r
this\r
\r
class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.IconItemColumnModule.Base extends Backbone.View\r
tagName: 'div'\r
events: {\r
- 'click .face': 'show'\r
+ 'click .face': 'profiler'\r
}\r
\r
initialize: (options) ->\r
this.$el.html(template(args))\r
this\r
\r
- show: () ->\r
- item = new Pettanr.Artist({id: 1})\r
- item.fetch().done ->\r
- profiler = new Locmare.Profiler({item_name: item.item_name(), item: item, operators: window.operators})\r
+ profiler: () ->\r
+ controller = Manifest.manifest().controllers[@item.table_name()]\r
+ action = controller.actions['show']\r
+ params = {\r
+ controller: controller,\r
+ action: action,\r
+ id: @item.get('id'),\r
+ format: 'prof'\r
+ }\r
+ window.router.navigate(action.url(params), true)\r
+ return false\r
\r
filer: () ->\r
@file_item.filer()\r
super(options)\r
\r
render: () ->\r
- i = new Pettanr.AppHelperImg({src: @icon_file_name(), size: @icon_size()})\r
- this.$el.html(i.render().el)\r
+ i = new Pettanr.AppHelperImg({class_name: 'face', src: @icon_file_name(), size: @icon_size()})\r
+ a = new Pettanr.AppHelperA({href: @path_name(), content: i.render().el})\r
+ this.$el.html(a.render().el)\r
this\r
\r
path_name: () ->\r
\r
@profiler_manifest = LocalManifest.manifest().profilers[@item_name]\r
@template_dir = 'templates-profiler-'\r
- @header = new Locmare.ProfilerModule.Header({profiler: this})\r
- @columns = new Locmare.ProfilerModule.Column({profiler: this})\r
- @associations = new Locmare.ProfilerModule.Association({'profiler': this, association_manifest: @profiler_manifest.associations})\r
- @render()\r
+ _this = this\r
+ @item.fetch().done ->\r
+ _this.header = new Locmare.ProfilerModule.Header({profiler: _this})\r
+ _this.columns = new Locmare.ProfilerModule.Column({profiler: _this})\r
+ _this.associations = new Locmare.ProfilerModule.Association({'profiler': _this, association_manifest: _this.profiler_manifest.associations})\r
+ _this.render()\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(@header.render().el)\r
this.$el.append(@columns.render().el)\r
this.$el.append(@associations.render().el)\r
- $("#pettanr").html(this.el)\r
this\r
\r
peta: () ->\r
new Locmare.ProfilerModule.AssociationModule.HasMany({association: this, has_many_manifest: list_manifest})\r
@has_one = _.map @association_manifest.has_one, (list_manifest) =>\r
new Locmare.ProfilerModule.AssociationModule.HasOne({association: this, has_one_manifest: list_manifestt})\r
- @render\r
+ @render()\r
\r
render: () ->\r
_this = this\r
_.each @belongs_to, (f) ->\r
- #_this.$el.append(f.render().el)\r
+ _this.$el.append(f.render().el)\r
_.each @has_many, (f) ->\r
- #_this.$el.append(f.render().el)\r
+ _this.$el.append(f.render().el)\r
_.each @has_one, (f) ->\r
- #_this.$el.append(f.render().el)\r
+ _this.$el.append(f.render().el)\r
this\r
\r
item: () ->\r
initialize: (options) ->\r
@association = options.association\r
@belongs_to_manifest = options.belongs_to_manifest\r
- @filer = null\r
- m = new @parent_model({id: @parent_id()})\r
- _this = this\r
- m.fetch().done ->\r
- _this.filer = new Locmare.Filer(@parent_model.item_name, r, null, @profiler().operators)\r
- _this.render()\r
+ pm = @parent_model()\r
+ m = new pm({id: @parent_id()})\r
+ @filer = new Locmare.Filer({\r
+ item_name: @parent_model().item_name(), \r
+ collection: m, \r
+ pager: null, \r
+ operators: @profiler().operators\r
+ })\r
\r
render: () ->\r
- this.$el.html('')\r
- if @filer\r
- this.$el.html(@filer.render().el)\r
+ this.$el.html(@filer.el)\r
this\r
\r
item: () ->\r
- @profiler.item\r
+ @profiler().item\r
\r
parent_model: () ->\r
@belongs_to_manifest.model()\r
\r
parent_id: () ->\r
- @item().get(@model_belongs_to_manifest().id_column)\r
+ c = @model_belongs_to_manifest().id_column\r
+ @item().get(c)\r
\r
model_manifest: () ->\r
- Manifest.manifest().models[@profiler.item_name]\r
+ Manifest.manifest().models[@profiler().item_name]\r
\r
model_belongs_to_manifest: () ->\r
@model_manifest().associations.belongs_to[@belongs_to_manifest.model_name]\r
\r
profiler: () ->\r
- @association.profiler()\r
+ @association.profiler\r
\r
initialize: (options) ->\r
@association = options.association\r
@has_many_manifest = options.has_many_manifest\r
- @filer = null\r
- m = new Pettanr.FilerCollection({}, @has_many_manifest.list_options(@item().get('id')))\r
- _this = this\r
- m.fetch().done ->\r
- items = m.models\r
- #_this.filer = new Locmare.Filer(_this.has_many_model().item_name, items, @pager, _this.profiler().operators)\r
- _this.render()\r
+ c = @has_many_manifest.list_options(@item().get('id'))\r
+ m = new Pettanr.FilerCollection({}, c)\r
+ @filer = new Locmare.Filer({\r
+ item_name: @has_many_model().item_name(), \r
+ collection: m, \r
+ pager: @pager, \r
+ operators: @profiler().operators\r
+ })\r
\r
render: () ->\r
- this.$el.html('')\r
- if @filer\r
- this.$el.html(@filer.render().el)\r
+ this.$el.html(@filer.el)\r
this\r
\r
item: () ->\r
@association = options.association\r
@has_one_manifest = options.has_one_manifest\r
@filer = null\r
- m = new @parent_model(@parent_id())\r
- m = new Pettanr.FilerCollection({}, @has_one_manifest.list_options(@item().get('id')))\r
- _this = this\r
- m.fetch().done ->\r
- items = m.models\r
- _this.filer = new Locmare.Filer(_this.has_one_model().item_name, items, null, _this.profiler().operators)\r
- _this.render()\r
+ c = @has_one_manifest.list_options(@item().get('id'))\r
+ m = new Pettanr.FilerCollection({}, c)\r
+ @filer = new Locmare.Filer({\r
+ item_name: @has_one_model().item_name(), \r
+ collection: m, \r
+ pager: @pager, \r
+ operators: @profiler().operators\r
+ })\r
\r
render: () ->\r
this.$el.html('')\r
this\r
\r
note: () ->\r
- Pettanr.AppHelper.t_selected_item(@select_item_name, @column.value())\r
+ Pettanr.AppHelper.t_selected_item(@select_item_name(), @column.value.value())\r
\r
is_visible:() ->\r
true\r
@model_attribute_source_manifest().select_item_name\r
\r
model_manifest: () ->\r
- Manifest.manifest().models[@column.profiler().item_name]\r
+ Manifest.manifest().models[@column.profiler.item_name]\r
\r
model_attribute_manifest: () ->\r
@model_manifest().attributes[@column.column_name]\r
\r
initialize: (options) ->\r
@profiler = options.profiler\r
+ @filer = new Locmare.Filer({\r
+ item_name: @profiler.item_name, \r
+ collection: @profiler.item, \r
+ pager: @pager, \r
+ operators: @profiler.operators\r
+ })\r
\r
render: () ->\r
- #this.$el.append(@filer().render().el)\r
+ this.$el.html(@filer.el)\r
this\r
\r
- filer: () ->\r
- new Locmare.Filer(@profiler.item_name, [@profiler.item], null, @profiler.operators)\r
- \r
$.getJSON('/local_manifest.json', null, (data) =>\r
loaded_local_manifest = new LocalManifest(data)\r
)\r
- $.ajaxSetup({async: true})\r
- Manifest.set_manifest(loaded_manifest)\r
- LocalManifest.set_manifest(loaded_local_manifest)\r
- loaded_manifest.init()\r
- loaded_local_manifest.init()\r
author = new Pettanr.Author({id: author_id})\r
author.fetch({})\r
artist = new Pettanr.Artist({id: artist_id})\r
artist.fetch({})\r
window.operators = new Pettanr.Operator([author, artist])\r
+ $.ajaxSetup({async: true})\r
+ Manifest.set_manifest(loaded_manifest)\r
+ LocalManifest.set_manifest(loaded_local_manifest)\r
+ loaded_manifest.init()\r
+ loaded_local_manifest.init()\r
\r
- #list_result = new Pettanr.Folder.Root({})\r
- #new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
window.router = new Pettanr.Router()\r
Backbone.history.start({pushState: true})\r
window.router.navigate('', true)\r
\r
encode_url: (action_name, params) ->\r
c = @parent.name\r
- a = if action_name != 'index'\r
+ a = if action_name == 'index' or action_name == 'show'\r
+ ''\r
+ else\r
'/' + action_name\r
+ # f = if params['format'] # json request? so bad. html request as get rest api\r
+ f = if params['format'] == 'prof'\r
+ '.' + params['format']\r
else\r
''\r
i = if params['id']\r
q = @encode_query(params)\r
switch @param_id\r
when 'prefix'\r
- c + i + a + q\r
+ c + i + a + f + q\r
when 'suffix'\r
- c + a + i + q\r
+ c + a + i + f + q\r
else\r
- c + a + q\r
+ c + a + f + q\r
\r
url: (params) ->\r
@encode_url(@name, params)\r
r\r
\r
tmb_opt_img_tag: (picture) ->\r
- wh = Pettanr.Imager.thumbnail_size(picture().get('width'), picture().get('height'))\r
+ wh = Pettanr.Imager.thumbnail_size(picture.get('width'), picture.get('height'))\r
new Pettanr.AppHelperImg({src: picture.r_url(), size: Math.abs(wh[0]), alt: @get('caption')})\r
\r
symbol_option: (cb) ->\r
class Pettanr.Panel extends Peta.Root\r
- @single: () ->\r
+ url: '/panels/'\r
+ @singular: () ->\r
'Panel'\r
\r
@plural: () ->\r
if @is_a_string(str)\r
str\r
else\r
- ''\r
+ if @is_number(str)\r
+ str.toString()\r
+ else\r
+ ''\r
\r
class Pettanr.AppHelper\r
@manifest: () ->\r
@t_selected_item: (name, index) ->\r
I18n.t(Manifest.manifest().system_resources.select_items[name][index][0])\r
\r
+ class Pettanr.AppHelperA extends Backbone.View\r
+ tagName: 'a'\r
+ \r
+ initialize: (options) ->\r
+ @href = options.href\r
+ @content = options.content\r
+ \r
+ render: () ->\r
+ this.$el.attr('href', @href)\r
+ this.$el.html(@content)\r
+ this\r
+ \r
+ \r
class Pettanr.AppHelperImg extends Backbone.View\r
tagName: 'img'\r
\r
initialize: (options) ->\r
@src = options.src\r
@size = options.size\r
+ @class_name = options.class_name\r
\r
render: () ->\r
this.$el.attr('src', @src)\r
this.$el.attr('width', @size)\r
this.$el.attr('height', @size)\r
+ @el.className = @class_name\r
this\r
\r
@image_tag: (src, opt = {}) ->\r
class Pettanr.AppController\r
constructor: () ->\r
@params = {}\r
+ @operators = window.operators\r
\r
set_model: () ->\r
@my_controller = Manifest.manifest().controllers[@params['controller']]\r
@pager = new Pettanr.Pager({action: @my_action, params: @params})\r
@list = new Pettanr.FilerCollection({}, {model: @my_list_model_class, action: @my_action, params: @params})\r
\r
+ set_show: () ->\r
+ @set_model()\r
+ @item = new @my_model_class({id: @params['id']})\r
+ \r
filer_list: () ->\r
@set_list()\r
f = new Locmare.Filer({\r
item_name: @my_list_model_class.item_name(), \r
collection: @list, \r
pager: @pager, \r
- operators: window.operators\r
+ operators: @operators\r
+ })\r
+ \r
+ show_prof: () ->\r
+ profiler = new Locmare.Profiler({\r
+ el: "#pettanr",\r
+ item_name: @item.item_name(), \r
+ item: @item, \r
+ operators: @operators\r
})\r
\r
class Pettanr.FilerRender\r