class Pettanr.Proxy\r
\r
constructor: (options) ->\r
- @operators = options.operators\r
+ @gate = options.gate\r
_.extend(this, Backbone.Events)\r
\r
local_router: (parsed_callback) ->\r
- local_router = new Pettanr.LocalRouter({operators: @operators})\r
+ local_router = new Pettanr.LocalRouter({})\r
@listenTo(local_router, 'go', parsed_callback)\r
- @listenTo(local_router, 'deny', @deny)\r
- @listenTo(local_router, 'cancel', @cancel)\r
local_router\r
\r
http_get: (url, form) ->\r
@local_router(@get).navigate(url, form)\r
\r
get: (params, form) ->\r
- controller = Pettanr.AppController.new2(params, form, @operators)\r
+ return if !@test(params, form)\r
+ return if !@filter(params, form)\r
+ controller = Pettanr.AppController.new2(params, form, @gate)\r
+ @add_get_listener(controller)\r
+ action_name = params['action']\r
+ controller[action_name]()\r
+ \r
+ add_get_listener: (controller) ->\r
@listenTo(controller, 'ready', @ready)\r
@listenTo(controller, 'title', @title)\r
@listenTo(controller, 'done', @done)\r
+ @listenTo(controller, 'other', @other)\r
+ @listenTo(controller, 'deny', @remote_folder_deny)\r
@listenTo(controller, 'lock', @lock)\r
- action_name = params['action']\r
- controller[action_name]()\r
+ @listenTo(controller, 'unlock', @unlock)\r
+ \r
+ test: (params, form) ->\r
+ return true if !@gate\r
+ switch @gate.test()\r
+ when 0\r
+ # free\r
+ true\r
+ when 1\r
+ # agree move\r
+ @gate.unlock()\r
+ true\r
+ else\r
+ # blocking\r
+ # back button event\r
+ Backbone.history.navigate('/' + @gate.url(), {trigger: false})\r
+ @trigger('cancel', params, form)\r
+ false\r
+ \r
+ filter: (params, form) ->\r
+ if safe_url = Pettanr.ActionFilter.test(params)\r
+ @trigger('deny', params, form, safe_url)\r
+ false\r
+ else\r
+ true\r
\r
ready: (view) ->\r
@trigger('ready', view)\r
done: (params) ->\r
@trigger('done', params)\r
\r
- lock: (params) ->\r
- @trigger('lock', params)\r
+ other: (url) ->\r
+ @local_router(@get).navigate(url)\r
+ \r
+ lock: (params, form) ->\r
+ @trigger('lock', params, form)\r
+ \r
+ unlock: (params, form) ->\r
+ @trigger('unlock', params, form)\r
\r
deny: (params, form, safe_url) ->\r
@trigger('deny', params, form, safe_url)\r
\r
- cancel: () ->\r
- @trigger('cancel')\r
+ remote_folder_deny: (params, form, safe_url) ->\r
+ @trigger('deny', params, form, safe_url)\r
\r
http_post: (url, form) ->\r
@local_router(@post).navigate(url, form)\r
\r
post: (params, form) ->\r
- controller = Pettanr.AppController.new2(params, form, @operators)\r
+ controller = Pettanr.AppController.new2(params, form)\r
@listenTo(controller, 'success', @success)\r
@listenTo(controller, 'fail', @fail)\r
@listenTo(controller, 'redirect', @redirect)\r
@listenTo(controller, 'sign_in', @sign_in)\r
@listenTo(controller, 'sign_out', @sign_out)\r
+ @listenTo(controller, 'lock', @lock)\r
+ @listenTo(controller, 'unlock', @unlock)\r
action_name = params['action']\r
controller[action_name]()\r
\r
sign_out: () ->\r
@trigger('sign_out')\r
\r
+ @destroy: (item, options = {}) ->\r
+ return if !confirm('remove?')\r
+ proxy = new Pettanr.Proxy({})\r
+ proxy.listenTo(proxy, 'success', options['success'])\r
+ proxy.listenTo(proxy, 'redirect', options['redirect'])\r
+ proxy.listenTo(proxy, 'fail', options['fail'])\r
+ proxy.listenTo(proxy, 'deny', options['deny'])\r
+ proxy.http_post(item.destroy_url())\r
+ \r
+class Pettanr.PickerProxy extends Pettanr.Proxy\r
+ \r
+ constructor: (options) ->\r
+ super(options)\r
+ \r
+ get: (params, form) ->\r
+ if @is_deny(params)\r
+ alert("editor can't open on pick window")\r
+ else\r
+ super(params, form)\r
+ \r
+ is_deny: (params) ->\r
+ c = Pettanr.AppController.controller_by_name(params['controller'])\r
+ return false if !c['is_deny_action_on_picker']\r
+ c.is_deny_action_on_picker(params)\r
+ \r
+class Pettanr.PublisherProxy extends Pettanr.Proxy\r
+ \r
+ add_get_listener: (controller) ->\r
+ super(controller)\r
+ # dialog send success message on select lisence_group select-box\r
+ @listenTo(controller, 'next', @next)\r
+ # dialog send success message on opl submit button\r
+ \r
+ next: (opl) ->\r
+ @trigger('next', opl)\r
+ \r