Add richtext feature to popovers.

This commit is contained in:
Martin Edenhofer 2014-12-28 14:57:37 +01:00
parent 24b80de0ea
commit 8247cdbf51
4 changed files with 74 additions and 44 deletions

View file

@ -270,28 +270,26 @@ class App.Controller extends Spine.Controller
user = App.User.fullLocal( user_id ) user = App.User.fullLocal( user_id )
# get display data # get display data
data = [] userData = []
for item2 in App.User.configure_attributes for attributeName, attributeConfig of App.User.attributesGet('view')
item = _.clone( item2 )
# check if value for _id exists # check if value for _id exists
itemNameValue = item.name name = attributeName
itemNameValueNew = itemNameValue.substr( 0, itemNameValue.length - 3 ) nameNew = name.substr( 0, name.length - 3 )
if itemNameValueNew of user if nameNew of user
item.name = itemNameValueNew name = nameNew
# add to show if value exists # add to show if value exists
if user[item.name] if user[name] && attributeConfig.shown
# do not show firstname and lastname / already show via diplayName() # do not show firstname and lastname / already show via diplayName()
if item.name isnt 'firstname' && item.name isnt 'lastname' && item.name isnt 'organization' if name isnt 'firstname' && name isnt 'lastname' && name isnt 'organization'
if item.info #&& ( @user[item.name] || item.name isnt 'note' ) userData.push attributeConfig
data.push item
# insert data # insert data
App.view('popover/user')( App.view('popover/user')(
user: user, user: user
data: data, userData: userData
) )
) )
@ -317,9 +315,28 @@ class App.Controller extends Spine.Controller
content: -> content: ->
organization_id = $(@).data('id') organization_id = $(@).data('id')
organization = App.Organization.fullLocal( organization_id ) organization = App.Organization.fullLocal( organization_id )
# get display data
organizationData = []
for attributeName, attributeConfig of App.Organization.attributesGet('view')
# check if value for _id exists
name = attributeName
nameNew = name.substr( 0, name.length - 3 )
if nameNew of organization
name = nameNew
# add to show if value exists
if organization[name] && attributeConfig.shown
# do not show firstname and lastname / already show via diplayName()
if name isnt 'name'
organizationData.push attributeConfig
# insert data # insert data
App.view('popover/organization')( App.view('popover/organization')(
organization: organization, organization: organization,
organizationData: organizationData,
) )
) )

View file

@ -202,6 +202,11 @@ class Table extends App.ControllerContent
attribute.data = attribute.data =
id: refObject.id id: refObject.id
value value
callbackOrganizationPopover = (value, object, attribute, attributes, refObject) =>
attribute.class = 'organization-popover'
attribute.data =
id: refObject.id
value
callbackCheckbox = (id, checked, e) => callbackCheckbox = (id, checked, e) =>
if @el.find('table').find('input[name="bulk"]:checked').length == 0 if @el.find('table').find('input[name="bulk"]:checked').length == 0
@el.find('.bulkAction').addClass('hide') @el.find('.bulkAction').addClass('hide')
@ -243,6 +248,8 @@ class Table extends App.ControllerContent
[ callbackIcon ] [ callbackIcon ]
customer_id: customer_id:
[ callbackUserPopover ] [ callbackUserPopover ]
organization_id:
[ callbackOrganizationPopover ]
owner_id: owner_id:
[ callbackUserPopover ] [ callbackUserPopover ]
title: title:
@ -259,6 +266,9 @@ class Table extends App.ControllerContent
# start user popups # start user popups
@userPopups() @userPopups()
# start organization popups
@organizationPopups()
# show frontend times # show frontend times
@frontendTimeUpdate() @frontendTimeUpdate()

View file

@ -1,17 +1,17 @@
<table style="width: 100%;"> <% for row in @organizationData: %>
<tr> <% if @organization[row.name]: %>
<td><%- @T( 'Shared' ) %></td> <% if row.tag is 'richtext': %>
<td><%- @P( @organization.shared ) %></td> <div class="customer-info" title="<%- @Ti( row.display ) %>"><%- @organization[row.name] %></div>
</tr> <% else: %>
<tr> <div class="customer-info" title="<%- @Ti( row.display ) %>"><%- @L( @P( @organization[row.name] ) ) %></div>
<td><%- @T( 'Note' ) %></td> <% end %>
<td><%- @P( @organization.note ) %></td> <% end %>
</tr> <% end %>
</table> <% if @organization.members: %>
<% if @organization.users: %> <hr>
<strong><%- @T('Users') %></strong> <%- @T('Members') %>
<ul> <ul>
<% for user in @organization.users: %> <% for user in @organization.members: %>
<li><%= user.displayName() %></li> <li><%= user.displayName() %></li>
<% end %> <% end %>
</ul> </ul>

View file

@ -1,13 +1,16 @@
<% for row in @data: %> <% if @user['organization']: %>
<div class="customer-info">
<%- @P( @user['organization'] ) %>
</div>
<% end %>
<% for row in @userData: %>
<% if @user[row.name]: %> <% if @user[row.name]: %>
<% if row.tag is 'richtext': %>
<div class="customer-info" title="<%- @Ti( row.display ) %>"><%- @user[row.name] %></div>
<% else: %>
<div class="customer-info" title="<%- @Ti( row.display ) %>"><%- @L( @P( @user[row.name] ) ) %></div> <div class="customer-info" title="<%- @Ti( row.display ) %>"><%- @L( @P( @user[row.name] ) ) %></div>
<% end %> <% end %>
<% end %> <% end %>
<% if @user['organization']: %>
<div class="customer-info">
<strong><%- @T( 'Organization' ) %></strong><br/>
<%- @P( @user['organization'] ) %>
</div>
<% end %> <% end %>
<% if !_.isEmpty(@user['accounts']): %> <% if !_.isEmpty(@user['accounts']): %>
<div class="customer-info"> <div class="customer-info">