Improved contenteditabe for user and org attributes.
This commit is contained in:
parent
449f0a69c4
commit
406eae642d
8 changed files with 92 additions and 128 deletions
|
@ -1,6 +1,6 @@
|
|||
class App.OrganizationProfile extends App.Controller
|
||||
events:
|
||||
'focusout [data-type=update]': 'update'
|
||||
'focusout [contenteditable]': 'update'
|
||||
|
||||
constructor: (params) ->
|
||||
super
|
||||
|
@ -50,22 +50,20 @@ class App.OrganizationProfile extends App.Controller
|
|||
|
||||
# get display data
|
||||
organizationData = []
|
||||
for item2 in App.Organization.configure_attributes
|
||||
item = _.clone( item2 )
|
||||
for attributeName, attributeConfig of App.Organization.attributesGet('view')
|
||||
|
||||
# check if value for _id exists
|
||||
itemNameValue = item.name
|
||||
itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
|
||||
if itemNameValueNew of organization
|
||||
item.name = itemNameValueNew
|
||||
name = attributeName
|
||||
nameNew = name.substr( 0, name.length - 3 )
|
||||
if nameNew of organization
|
||||
name = nameNew
|
||||
|
||||
# add to show if value exists
|
||||
if organization[item.name] || item.tag is 'textarea'
|
||||
if organization[name] && attributeConfig.shown
|
||||
|
||||
# do not show firstname and lastname / already show via diplayName()
|
||||
if item.name isnt 'name'
|
||||
if item.info
|
||||
organizationData.push item
|
||||
if name isnt 'name'
|
||||
organizationData.push attributeConfig
|
||||
|
||||
@html App.view('organization_profile')(
|
||||
organization: organization
|
||||
|
@ -120,12 +118,14 @@ class App.OrganizationProfile extends App.Controller
|
|||
)
|
||||
|
||||
update: (e) =>
|
||||
console.log('update')
|
||||
note = $(e.target).ceg()
|
||||
org = App.Organization.find( @organization_id )
|
||||
if org.note isnt note
|
||||
org.updateAttributes( note: note )
|
||||
@log 'notice', 'update', e, note, org
|
||||
name = $(e.target).attr('data-name')
|
||||
value = $(e.target).html()
|
||||
org = App.Organization.find( @organization_id )
|
||||
if org[name] isnt value
|
||||
data = {}
|
||||
data[name] = value
|
||||
org.updateAttributes( data )
|
||||
@log 'notice', 'update', name, value, org
|
||||
|
||||
class Router extends App.ControllerPermanent
|
||||
constructor: (params) ->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class App.UserProfile extends App.Controller
|
||||
events:
|
||||
'focusout [data-type=update]': 'update'
|
||||
'focusout [contenteditable]': 'update'
|
||||
|
||||
constructor: (params) ->
|
||||
super
|
||||
|
@ -49,22 +49,20 @@ class App.UserProfile extends App.Controller
|
|||
|
||||
# get display data
|
||||
userData = []
|
||||
for item2 in App.User.configure_attributes
|
||||
item = _.clone( item2 )
|
||||
for attributeName, attributeConfig of App.User.attributesGet('view')
|
||||
|
||||
# check if value for _id exists
|
||||
itemNameValue = item.name
|
||||
itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
|
||||
if itemNameValueNew of user
|
||||
item.name = itemNameValueNew
|
||||
name = attributeName
|
||||
nameNew = name.substr( 0, name.length - 3 )
|
||||
if nameNew of user
|
||||
name = nameNew
|
||||
|
||||
# add to show if value exists
|
||||
if user[item.name] || item.tag is 'textarea'
|
||||
if user[name] && attributeConfig.shown
|
||||
|
||||
# do not show firstname and lastname / already show via diplayName()
|
||||
if item.name isnt 'firstname' && item.name isnt 'lastname' && item.name isnt 'organization'
|
||||
if item.info
|
||||
userData.push item
|
||||
if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization'
|
||||
userData.push attributeConfig
|
||||
|
||||
@html App.view('user_profile')(
|
||||
user: user
|
||||
|
@ -120,12 +118,14 @@ class App.UserProfile extends App.Controller
|
|||
)
|
||||
|
||||
update: (e) =>
|
||||
console.log('update')
|
||||
note = $(e.target).ceg()
|
||||
user = App.User.find( @user_id )
|
||||
if user.note isnt note
|
||||
user.updateAttributes( note: note )
|
||||
@log 'notice', 'update', e, note, user
|
||||
name = $(e.target).attr('data-name')
|
||||
value = $(e.target).html()
|
||||
user = App.User.find( @user_id )
|
||||
if user[name] isnt value
|
||||
data = {}
|
||||
data[name] = value
|
||||
user.updateAttributes( data )
|
||||
@log 'notice', 'update', name, value, user
|
||||
|
||||
class Router extends App.ControllerPermanent
|
||||
constructor: (params) ->
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class App.WidgetOrganization extends App.Controller
|
||||
events:
|
||||
'focusout [data-type=update-org]': 'update',
|
||||
'click [data-type=edit-org]': 'edit'
|
||||
'focusout [contenteditable]': 'update'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
@ -18,22 +17,20 @@ class App.WidgetOrganization extends App.Controller
|
|||
|
||||
# get display data
|
||||
organizationData = []
|
||||
for item2 in App.Organization.configure_attributes
|
||||
item = _.clone( item2 )
|
||||
for attributeName, attributeConfig of App.Organization.attributesGet('view')
|
||||
|
||||
# check if value for _id exists
|
||||
itemNameValue = item.name
|
||||
itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
|
||||
if itemNameValueNew of organization
|
||||
item.name = itemNameValueNew
|
||||
name = attributeName
|
||||
nameNew = name.substr( 0, name.length - 3 )
|
||||
if nameNew of organization
|
||||
name = nameNew
|
||||
|
||||
# add to show if value exists
|
||||
if organization[item.name] || item.tag is 'textarea'
|
||||
if organization[name] && attributeConfig.shown
|
||||
|
||||
# do not show name / already show via diplayName()
|
||||
if item.name isnt 'name'
|
||||
if item.info
|
||||
organizationData.push item
|
||||
# do not show firstname and lastname / already show via diplayName()
|
||||
if name isnt 'name'
|
||||
organizationData.push attributeConfig
|
||||
|
||||
# insert userData
|
||||
@html App.view('widget/organization')(
|
||||
|
@ -41,7 +38,7 @@ class App.WidgetOrganization extends App.Controller
|
|||
organizationData: organizationData
|
||||
)
|
||||
|
||||
@$('div [contenteditable]').ce(
|
||||
@$('[contenteditable]').ce(
|
||||
mode: 'textonly'
|
||||
multiline: true
|
||||
maxlength: 250
|
||||
|
@ -59,21 +56,11 @@ class App.WidgetOrganization extends App.Controller
|
|||
###
|
||||
|
||||
update: (e) =>
|
||||
note = $(e.target).ceg()
|
||||
organization = App.Organization.find( @organization_id )
|
||||
if organization.note isnt note
|
||||
organization.updateAttributes( note: note )
|
||||
@log 'notice', 'update', e, note, organization
|
||||
|
||||
edit: (e) =>
|
||||
e.preventDefault()
|
||||
new App.ControllerGenericEdit(
|
||||
id: @organization_id,
|
||||
genericObject: 'Organization',
|
||||
pageData: {
|
||||
title: 'Organizations',
|
||||
object: 'Organization',
|
||||
objects: 'Organizations',
|
||||
},
|
||||
callback: @render
|
||||
)
|
||||
name = $(e.target).attr('data-name')
|
||||
value = $(e.target).html()
|
||||
org = App.Organization.find( @organization_id )
|
||||
if org[name] isnt value
|
||||
data = {}
|
||||
data[name] = value
|
||||
org.updateAttributes( data )
|
||||
@log 'notice', 'update', name, value, org
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class App.WidgetUser extends App.Controller
|
||||
events:
|
||||
'focusout [data-type=update]': 'update',
|
||||
'click [data-type=edit]': 'edit'
|
||||
'focusout [contenteditable]': 'update'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
@ -20,22 +19,20 @@ class App.WidgetUser extends App.Controller
|
|||
|
||||
# get display data
|
||||
userData = []
|
||||
for item2 in App.User.configure_attributes
|
||||
item = _.clone( item2 )
|
||||
for attributeName, attributeConfig of App.User.attributesGet('view')
|
||||
|
||||
# check if value for _id exists
|
||||
itemNameValue = item.name
|
||||
itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 )
|
||||
if itemNameValueNew of user
|
||||
item.name = itemNameValueNew
|
||||
name = attributeName
|
||||
nameNew = name.substr( 0, name.length - 3 )
|
||||
if nameNew of user
|
||||
name = nameNew
|
||||
|
||||
# add to show if value exists
|
||||
if user[item.name] || item.tag is 'textarea'
|
||||
if user[name] && attributeConfig.shown
|
||||
|
||||
# do not show firstname and lastname / already show via diplayName()
|
||||
if item.name isnt 'firstname' && item.name isnt 'lastname'
|
||||
if item.info
|
||||
userData.push item
|
||||
if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization'
|
||||
userData.push attributeConfig
|
||||
|
||||
if user.preferences
|
||||
items = []
|
||||
|
@ -67,13 +64,13 @@ class App.WidgetUser extends App.Controller
|
|||
|
||||
# insert userData
|
||||
@html App.view('widget/user')(
|
||||
header: 'Customer'
|
||||
edit: true
|
||||
header: 'Customer'
|
||||
edit: true
|
||||
user: user
|
||||
userData: userData
|
||||
)
|
||||
|
||||
@$('div[contenteditable]').ce(
|
||||
@$('[contenteditable]').ce(
|
||||
mode: 'textonly'
|
||||
multiline: true
|
||||
maxlength: 250
|
||||
|
@ -86,21 +83,11 @@ class App.WidgetUser extends App.Controller
|
|||
)
|
||||
|
||||
update: (e) =>
|
||||
note = $(e.target).ceg()
|
||||
user = App.User.find( @user_id )
|
||||
if user.note isnt note
|
||||
user.updateAttributes( note: note )
|
||||
@log 'notice', 'update', e, note, user
|
||||
|
||||
edit: (e) =>
|
||||
e.preventDefault()
|
||||
new App.ControllerGenericEdit(
|
||||
id: @user_id
|
||||
genericObject: 'User'
|
||||
screen: 'edit'
|
||||
pageData:
|
||||
title: 'Users'
|
||||
object: 'User'
|
||||
objects: 'Users'
|
||||
callback: @render
|
||||
)
|
||||
name = $(e.target).attr('data-name')
|
||||
value = $(e.target).html()
|
||||
user = App.User.find( @user_id )
|
||||
if user[name] isnt value
|
||||
data = {}
|
||||
data[name] = value
|
||||
user.updateAttributes( data )
|
||||
@log 'notice', 'update', name, value, user
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="profile-details horizontal wrap">
|
||||
<% for row in @organizationData: %>
|
||||
<% if @organization[row.name]: %>
|
||||
<% if row.tag isnt 'textarea': %>
|
||||
<% if row.tag isnt 'richtext': %>
|
||||
<div class="profile-detailsEntry">
|
||||
<label><%- @Ti( row.display ) %></label>
|
||||
<%- @L( @P( @organization[row.name] ) ) %>
|
||||
|
@ -21,10 +21,10 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% for row in @organizationData: %>
|
||||
<% if row.tag is 'textarea': %>
|
||||
<% if row.tag is 'richtext': %>
|
||||
<div class="profile-detailsEntry" style="width: 100%;">
|
||||
<label><%- @Ti( row.display ) %></label>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%= @organization[row.name] %></div>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @organization[row.name] %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div class="profile-details horizontal wrap">
|
||||
<% for row in @userData: %>
|
||||
<% if @user[row.name]: %>
|
||||
<% if row.tag isnt 'textarea': %>
|
||||
<% if row.tag isnt 'richtext': %>
|
||||
<div class="profile-detailsEntry">
|
||||
<label><%- @Ti( row.display ) %></label>
|
||||
<%- @L( @P( @user[row.name] ) ) %>
|
||||
|
@ -23,10 +23,10 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% for row in @userData: %>
|
||||
<% if row.tag is 'textarea': %>
|
||||
<% if row.tag is 'richtext': %>
|
||||
<div class="profile-detailsEntry" style="width: 100%;">
|
||||
<label><%- @Ti( row.display ) %></label>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%= @user[row.name] %></div>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @user[row.name] %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
</div>
|
||||
|
||||
<% for row in @organizationData: %>
|
||||
<% if @organization[row.name] || row.name is 'note': %>
|
||||
<div class="sidebar-block">
|
||||
<% if row.tag isnt 'textarea': %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<%- @L( @P( @organization[row.name] ) ) %>
|
||||
<% else: %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update-org" data-placeholder="<%- @T('Add a Note') %>"><%= @organization[row.name] %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @organization[row.name] || row.name is 'note': %>
|
||||
<div class="sidebar-block">
|
||||
<% if row.tag isnt 'richtext': %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<%- @L( @P( @organization[row.name] ) ) %>
|
||||
<% else: %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update-org" data-placeholder="<%- @T('Add a Note') %>"><%- @organization[row.name] %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @organization.members: %>
|
||||
|
@ -29,16 +29,6 @@
|
|||
<a href="<%- user.uiUrl() %>" class="user-popover" data-id="<%- user.id %>">
|
||||
<%= user.displayName() %>
|
||||
</a>
|
||||
<li>
|
||||
<%- user.avatar("40") %>
|
||||
<a href="<%- user.uiUrl() %>" class="user-popover" data-id="<%- user.id %>">
|
||||
<%= user.displayName() %>
|
||||
</a>
|
||||
<li>
|
||||
<%- user.avatar("40") %>
|
||||
<a href="<%- user.uiUrl() %>" class="user-popover" data-id="<%- user.id %>">
|
||||
<%= user.displayName() %>
|
||||
</a>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<% for row in @userData: %>
|
||||
<% if @user[row.name] || row.name is 'note': %>
|
||||
<div class="sidebar-block">
|
||||
<% if row.tag isnt 'textarea': %>
|
||||
<% if row.tag isnt 'richtext': %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<%- @L( @P( @user[row.name] ) ) %>
|
||||
<% else: %>
|
||||
<label><%- @T( row.display ) %></label>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%= @user[row.name] %></div>
|
||||
<div contenteditable="true" data-name="<%= row.name %>" data-type="update" data-placeholder="<%- @T('Add a Note') %>"><%- @user[row.name] %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue