diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index e53b82bbf..257aa6716 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -422,7 +422,7 @@ class App.ControllerModal extends App.Controller # @callback.success = options.success # if options.error # @callback.error = options.error - + super(options) modalShow: (params) => @@ -443,7 +443,7 @@ class App.ControllerModal extends App.Controller # navigate back if params && params.navigateBack window.history.back() - + # remove modal from dom $('.modal').remove(); ) @@ -452,7 +452,7 @@ class App.ControllerModal extends App.Controller if e e.preventDefault() @el.modal('hide') - + submit: (e) => e.preventDefault() @log 'You need to implement your own "submit" method!' diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index e85a43818..bdbf98b5f 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -68,7 +68,7 @@ class App.ControllerGenericEdit extends App.ControllerModal @render() @genericObject.unbind 'refresh' @genericObject.fetch( id: params.id) - + render: -> @html App.view('generic/admin/edit')( head: @pageData.object ) @@ -76,6 +76,7 @@ class App.ControllerGenericEdit extends App.ControllerModal el: @el.find('#object_edit'), model: @genericObject, params: @item, + required: @required, autofocus: true, ) @@ -85,7 +86,7 @@ class App.ControllerGenericEdit extends App.ControllerModal e.preventDefault() params = @formParam(e.target) @item.load(params) - + # validate errors = @item.validate() if errors @@ -97,6 +98,7 @@ class App.ControllerGenericEdit extends App.ControllerModal # save object @item.save( success: => + @log 'lll', @callback(@item), @required @modalHide() error: => @log 'errors' diff --git a/app/assets/javascripts/app/controllers/user_info.js.coffee b/app/assets/javascripts/app/controllers/user_info.js.coffee index 79d3ec689..14b4fc047 100644 --- a/app/assets/javascripts/app/controllers/user_info.js.coffee +++ b/app/assets/javascripts/app/controllers/user_info.js.coffee @@ -2,7 +2,8 @@ $ = jQuery.sub() class App.UserInfo extends App.Controller events: - 'focusout [data-type=edit]': 'update', + 'focusout [data-type=update]': 'update', + 'click [data-type=edit]': 'edit' constructor: -> super @@ -28,11 +29,24 @@ class App.UserInfo extends App.Controller user_id: user.id, ) + # update changes update: (e) => - - # update changes - note = $(e.target).parent().find('[data-type=edit]').val() + note = $(e.target).parent().find('[data-type=update]').val() user = App.Collection.find( 'User', @user_id ) if user.note isnt note user.updateAttributes( note: note ) @log 'update', e, note, user + + edit: (e) => + e.preventDefault() + new App.ControllerGenericEdit( + id: @user_id, + genericObject: App.User, + required: 'quick', + pageData: { + title: 'Users', + object: 'User', + objects: 'Users', + }, + callback: @render + ) diff --git a/app/assets/javascripts/app/views/user_info.jst.eco b/app/assets/javascripts/app/views/user_info.jst.eco index 28b20e2b8..6fe7102dd 100644 --- a/app/assets/javascripts/app/views/user_info.jst.eco +++ b/app/assets/javascripts/app/views/user_info.jst.eco @@ -1,10 +1,10 @@
-

<%- T('Customer') %>

+

<%- T('Customer') %>

<% if @user.image: %> <% end %>
-
<%= @user['realname'] %>
+
<%= @user.displayName() %>
<% for row in @data: %> <% if @user[row.name] || row.name is 'note': %> @@ -14,7 +14,7 @@ <% else: %>
<%- T(row.display) %>
- +
<% end %>