From 29936d2acd02a61d8b271b71cb25f8cf197609d3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 13 Sep 2015 20:14:07 +0200 Subject: [PATCH] Small code cleanup. --- .../_application_controller_form.js.coffee | 32 +++++++++---------- .../app/controllers/manage.js.coffee | 1 - .../app/controllers/users.js.coffee | 8 +++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 5c769b8df..3696718ac 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -5,8 +5,8 @@ class App.ControllerForm extends App.Controller if !@handlers @handlers = [] - @handlers.push @_showHideToggle - @handlers.push @_requiredMandantoryToggle + @handlers.push @showHideToggle + @handlers.push @requiredMandantoryToggle # set empty class attributes if needed if !@form @@ -1063,16 +1063,16 @@ class App.ControllerForm extends App.Controller # check if value is used in condition if _.contains( action.bind.value, value ) if action.change.action is 'hide' - ui._hide(action.change.name) + ui.hide(action.change.name) else - ui._show(action.change.name) + ui.show(action.change.name) ) if !attribute.display # hide/show item #if attribute.hide - # @._hide(attribute.name) + # @.hide(attribute.name) return item else @@ -1087,11 +1087,11 @@ class App.ControllerForm extends App.Controller # hide/show item if attribute.hide - @._hide(attribute.name, fullItem) + @.hide(attribute.name, fullItem) return fullItem - _show: (name, el = @el) -> + show: (name, el = @el) -> if !_.isArray(name) name = [name] for key in name @@ -1105,7 +1105,7 @@ class App.ControllerForm extends App.Controller el.find('.has-error').removeClass('has-error') el.find('.help-inline').html('') - _hide: (name, el = @el) -> + hide: (name, el = @el) -> if !_.isArray(name) name = [name] for key in name @@ -1114,21 +1114,21 @@ class App.ControllerForm extends App.Controller el.find('[data-name="' + key + '"]').closest('.form-group').addClass('hide') el.find('[data-name="' + key + '"]').addClass('is-hidden') - _mandantory: (name, el = @el) -> + mandantory: (name, el = @el) -> if !_.isArray(name) name = [name] for key in name el.find('[name="' + key + '"]').attr('required', true) el.find('[name="' + key + '"]').parents('.form-group').find('label span').html('*') - _optional: (name, el = @el) -> + optional: (name, el = @el) -> if !_.isArray(name) name = [name] for key in name el.find('[name="' + key + '"]').attr('required', false) el.find('[name="' + key + '"]').parents('.form-group').find('label span').html('') - _showHideToggle: (params, changedAttribute, attributes, classname, form, ui) => + showHideToggle: (params, changedAttribute, attributes, classname, form, ui) => for attribute in attributes if attribute.shown_if hit = false @@ -1141,11 +1141,11 @@ class App.ControllerForm extends App.Controller else if params[refAttribute].toString() is refValue.toString() hit = true if hit - ui._show(attribute.name) + ui.show(attribute.name) else - ui._hide(attribute.name) + ui.hide(attribute.name) - _requiredMandantoryToggle: (params, changedAttribute, attributes, classname, form, ui) => + requiredMandantoryToggle: (params, changedAttribute, attributes, classname, form, ui) => for attribute in attributes if attribute.required_if hit = false @@ -1158,9 +1158,9 @@ class App.ControllerForm extends App.Controller else if params[refAttribute].toString() is refValue.toString() hit = true if hit - ui._mandantory(attribute.name) + ui.mandantory(attribute.name) else - ui._optional(attribute.name) + ui.optional(attribute.name) validate: (params) -> App.Model.validate( diff --git a/app/assets/javascripts/app/controllers/manage.js.coffee b/app/assets/javascripts/app/controllers/manage.js.coffee index 153a63d31..18eaca26b 100644 --- a/app/assets/javascripts/app/controllers/manage.js.coffee +++ b/app/assets/javascripts/app/controllers/manage.js.coffee @@ -7,7 +7,6 @@ App.Config.set( 'settings/:target', IndexRouter, 'Routes' ) App.Config.set( 'channels/:target', IndexRouter, 'Routes' ) App.Config.set( 'system/:target', IndexRouter, 'Routes' ) - App.Config.set( 'Manage', { prio: 1000, name: 'Manage', target: '#manage', role: ['Admin'] }, 'NavBarAdmin' ) App.Config.set( 'Channels', { prio: 2500, name: 'Channels', target: '#channels', role: ['Admin'] }, 'NavBarAdmin' ) App.Config.set( 'Settings', { prio: 7000, name: 'Settings', target: '#settings', role: ['Admin'] }, 'NavBarAdmin' ) diff --git a/app/assets/javascripts/app/controllers/users.js.coffee b/app/assets/javascripts/app/controllers/users.js.coffee index da5214660..e17ba7a40 100644 --- a/app/assets/javascripts/app/controllers/users.js.coffee +++ b/app/assets/javascripts/app/controllers/users.js.coffee @@ -2,7 +2,7 @@ class Index extends App.Controller elements: '.js-search' : 'searchInput' events: - 'click [data-type="new"]': 'new' + 'click [data-type="new"]': 'new' constructor: -> super @@ -60,7 +60,7 @@ class Index extends App.Controller header callbackAttributes = (value, object, attribute, header, refObject) -> - text = App.i18n.translateInline("View from user's perspective") + text = App.i18n.translateInline('View from user\'s perspective') value = ' ' attribute.raw = ' ' + text + '' attribute.class = '' @@ -84,7 +84,7 @@ class Index extends App.Controller @renderResult(user_ids) new App.ControllerGenericEdit( - id: item.id + id: item.id pageData: title: 'Users' home: 'users' @@ -93,6 +93,7 @@ class Index extends App.Controller navupdate: '#users' genericObject: 'User' callback: rerender + container: @el.closest('.content') ) users = [] @@ -175,6 +176,7 @@ class Index extends App.Controller objects: 'Users' navupdate: '#users' genericObject: 'User' + container: @el.closest('.content') ) App.Config.set( 'User', { prio: 1000, name: 'Users', parent: '#manage', target: '#manage/users', controller: Index, role: ['Admin'] }, 'NavBarAdmin' ) \ No newline at end of file