Fixed race condition if saving avatar image. Added image attribute in avatar observer controller.
This commit is contained in:
parent
054ad6ced3
commit
cb7d10fb1f
5 changed files with 17 additions and 14 deletions
|
@ -5,7 +5,7 @@ class App.ControllerGenericNew extends App.ControllerModal
|
||||||
headPrefix: 'New'
|
headPrefix: 'New'
|
||||||
|
|
||||||
content: =>
|
content: =>
|
||||||
@head = @pageData.object
|
@head = @pageData.head || @pageData.object
|
||||||
@controller = new App.ControllerForm(
|
@controller = new App.ControllerForm(
|
||||||
model: App[ @genericObject ]
|
model: App[ @genericObject ]
|
||||||
params: @item
|
params: @item
|
||||||
|
@ -53,7 +53,7 @@ class App.ControllerGenericEdit extends App.ControllerModal
|
||||||
|
|
||||||
content: =>
|
content: =>
|
||||||
@item = App[ @genericObject ].find( @id )
|
@item = App[ @genericObject ].find( @id )
|
||||||
@head = @pageData.object
|
@head = @pageData.head || @pageData.object
|
||||||
|
|
||||||
@controller = new App.ControllerForm(
|
@controller = new App.ControllerForm(
|
||||||
model: App[ @genericObject ]
|
model: App[ @genericObject ]
|
||||||
|
@ -1116,9 +1116,8 @@ class App.ObserverController extends App.Controller
|
||||||
if active
|
if active
|
||||||
currentAttributes[key] = object[key]
|
currentAttributes[key] = object[key]
|
||||||
if @observeNot
|
if @observeNot
|
||||||
attributes = object.attributes()
|
for key, value of object
|
||||||
for key, value of attributes
|
if !@observeNot[key] && !_.isFunction(value)
|
||||||
if !@observeNot[key]
|
|
||||||
currentAttributes[key] = value
|
currentAttributes[key] = value
|
||||||
|
|
||||||
if !@lastAttributres
|
if !@lastAttributres
|
||||||
|
|
|
@ -5,6 +5,7 @@ class App.WidgetAvatar extends App.ObserverController
|
||||||
firstname: true
|
firstname: true
|
||||||
lastname: true
|
lastname: true
|
||||||
email: true
|
email: true
|
||||||
|
image: true
|
||||||
|
|
||||||
render: (user) =>
|
render: (user) =>
|
||||||
@html(user.avatar @size, @position, undefined, false, false, @type)
|
@html(user.avatar @size, @position, undefined, false, false, @type)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class App.WidgetOrganization extends App.Controller
|
||||||
super
|
super
|
||||||
|
|
||||||
# subscribe and reload data / fetch new data if triggered
|
# subscribe and reload data / fetch new data if triggered
|
||||||
@subscribeId = App.Organization.full( @organization_id, @render, false, true )
|
@subscribeId = App.Organization.full(@organization_id, @render, false, true)
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
App.Organization.unsubscribe(@subscribeId)
|
App.Organization.unsubscribe(@subscribeId)
|
||||||
|
@ -58,9 +58,9 @@ class App.WidgetOrganization extends App.Controller
|
||||||
update: (e) =>
|
update: (e) =>
|
||||||
name = $(e.target).attr('data-name')
|
name = $(e.target).attr('data-name')
|
||||||
value = $(e.target).html()
|
value = $(e.target).html()
|
||||||
org = App.Organization.find( @organization_id )
|
org = App.Organization.find(@organization_id)
|
||||||
if org[name] isnt value
|
if org[name] isnt value
|
||||||
data = {}
|
data = {}
|
||||||
data[name] = value
|
data[name] = value
|
||||||
org.updateAttributes( data )
|
org.updateAttributes(data)
|
||||||
@log 'notice', 'update', name, value, org
|
@log 'notice', 'update', name, value, org
|
||||||
|
|
|
@ -6,7 +6,7 @@ class App.WidgetUser extends App.Controller
|
||||||
super
|
super
|
||||||
|
|
||||||
# subscribe and reload data / fetch new data if triggered
|
# subscribe and reload data / fetch new data if triggered
|
||||||
@subscribeId = App.User.full( @user_id, @render, false, true )
|
@subscribeId = App.User.full(@user_id, @render, false, true)
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
App.User.unsubscribe(@subscribeId)
|
App.User.unsubscribe(@subscribeId)
|
||||||
|
@ -85,9 +85,9 @@ class App.WidgetUser extends App.Controller
|
||||||
update: (e) =>
|
update: (e) =>
|
||||||
name = $(e.target).attr('data-name')
|
name = $(e.target).attr('data-name')
|
||||||
value = $(e.target).html()
|
value = $(e.target).html()
|
||||||
user = App.User.find( @user_id )
|
user = App.User.find(@user_id)
|
||||||
if user[name] isnt value
|
if user[name] isnt value
|
||||||
data = {}
|
data = {}
|
||||||
data[name] = value
|
data[name] = value
|
||||||
user.updateAttributes( data )
|
user.updateAttributes(data)
|
||||||
@log 'notice', 'update', name, value, user
|
@log 'notice', 'update', name, value, user
|
||||||
|
|
|
@ -733,7 +733,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
)
|
)
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: { avatar: avatar }, status: :ok
|
render json: { avatar: avatar }, status: :ok
|
||||||
end
|
end
|
||||||
|
@ -751,7 +752,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
avatar = Avatar.set_default('User', current_user.id, params[:id])
|
avatar = Avatar.set_default('User', current_user.id, params[:id])
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
@ -770,7 +772,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
|
|
||||||
# update user link
|
# update user link
|
||||||
avatar = Avatar.get_default('User', current_user.id)
|
avatar = Avatar.get_default('User', current_user.id)
|
||||||
current_user.update_attributes(image: avatar.store_hash)
|
user = User.find(current_user.id)
|
||||||
|
user.update_attributes(image: avatar.store_hash)
|
||||||
|
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue