Added table dnd support for sort prio in overviews.
This commit is contained in:
parent
34473a6d87
commit
00abecbd98
8 changed files with 41 additions and 6 deletions
|
@ -174,6 +174,8 @@ class App.ControllerGenericIndex extends App.Controller
|
||||||
'click': @edit
|
'click': @edit
|
||||||
container: @container
|
container: @container
|
||||||
explanation: @pageData.explanation or 'none'
|
explanation: @pageData.explanation or 'none'
|
||||||
|
groupBy: @groupBy
|
||||||
|
dndCallback: @dndCallback
|
||||||
},
|
},
|
||||||
@pageData.tableExtend
|
@pageData.tableExtend
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,6 +33,16 @@ class App.ControllerTable extends App.Controller
|
||||||
@html @tableGen()
|
@html @tableGen()
|
||||||
@readjustHeaderWidths()
|
@readjustHeaderWidths()
|
||||||
|
|
||||||
|
if @dndCallback
|
||||||
|
dndOptions =
|
||||||
|
tolerance: 'pointer'
|
||||||
|
distance: 15
|
||||||
|
opacity: 0.6
|
||||||
|
forcePlaceholderSize: true
|
||||||
|
items: 'tr'
|
||||||
|
update: @dndCallback
|
||||||
|
@el.find('table > tbody').sortable(dndOptions)
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
# table based on model
|
# table based on model
|
||||||
|
@ -103,6 +113,9 @@ class App.ControllerTable extends App.Controller
|
||||||
attributeName: [
|
attributeName: [
|
||||||
callbackAttributes
|
callbackAttributes
|
||||||
]
|
]
|
||||||
|
dndCallback: =>
|
||||||
|
items = @el.find('table > tbody > tr')
|
||||||
|
console.log('all effected items', items)
|
||||||
)
|
)
|
||||||
|
|
||||||
new App.ControllerTable(
|
new App.ControllerTable(
|
||||||
|
|
|
@ -9,6 +9,8 @@ class Index extends App.ControllerContent
|
||||||
el: @el
|
el: @el
|
||||||
id: @id
|
id: @id
|
||||||
genericObject: 'Overview'
|
genericObject: 'Overview'
|
||||||
|
defaultSortBy: 'prio'
|
||||||
|
#groupBy: 'role'
|
||||||
pageData:
|
pageData:
|
||||||
title: 'Overviews'
|
title: 'Overviews'
|
||||||
home: 'overviews'
|
home: 'overviews'
|
||||||
|
@ -22,7 +24,18 @@ class Index extends App.ControllerContent
|
||||||
{ name: 'New Overview', 'data-type': 'new', class: 'btn--success' }
|
{ name: 'New Overview', 'data-type': 'new', class: 'btn--success' }
|
||||||
]
|
]
|
||||||
container: @el.closest('.content')
|
container: @el.closest('.content')
|
||||||
large: true,
|
large: true
|
||||||
|
dndCallback: =>
|
||||||
|
items = @el.find('table > tbody > tr')
|
||||||
|
order = []
|
||||||
|
prio = 0
|
||||||
|
for item in items
|
||||||
|
prio += 1
|
||||||
|
id = $(item).data('id')
|
||||||
|
overview = App.Overview.find(id)
|
||||||
|
if overview.prio isnt prio
|
||||||
|
overview.prio = prio
|
||||||
|
overview.save()
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set( 'Overview', { prio: 2300, name: 'Overviews', parent: '#manage', target: '#manage/overviews', controller: Index, role: ['Admin'] }, 'NavBarAdmin' )
|
App.Config.set( 'Overview', { prio: 2300, name: 'Overviews', parent: '#manage', target: '#manage/overviews', controller: Index, role: ['Admin'] }, 'NavBarAdmin' )
|
|
@ -4,12 +4,13 @@ class App.Overview extends App.Model
|
||||||
@url: @apiPath + '/overviews'
|
@url: @apiPath + '/overviews'
|
||||||
@configure_attributes = [
|
@configure_attributes = [
|
||||||
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false },
|
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false },
|
||||||
|
{ name: 'link', display: 'Link', readonly: 1 },
|
||||||
{ name: 'role_id', display: 'Available for Role', tag: 'select', multiple: false, nulloption: true, null: false, relation: 'Role', translate: true },
|
{ name: 'role_id', display: 'Available for Role', tag: 'select', multiple: false, nulloption: true, null: false, relation: 'Role', translate: true },
|
||||||
{ name: 'user_id', display: 'Available for User', tag: 'select', multiple: true, nulloption: true, null: true, relation: 'User', sortBy: 'firstname' },
|
{ name: 'user_id', display: 'Available for User', tag: 'select', multiple: true, nulloption: true, null: true, relation: 'User', sortBy: 'firstname' },
|
||||||
{ name: 'organization_shared', display: 'Only available for Users with shared Organization', tag: 'select', options: { true: 'yes', false: 'no' }, default: false, null: true },
|
{ name: 'organization_shared', display: 'Only available for Users with shared Organization', tag: 'select', options: { true: 'yes', false: 'no' }, default: false, null: true },
|
||||||
# { name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false },
|
# { name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false },
|
||||||
{ name: 'condition', display: 'Conditions for shown Tickets', tag: 'ticket_selector', null: false },
|
{ name: 'condition', display: 'Conditions for shown Tickets', tag: 'ticket_selector', null: false },
|
||||||
{ name: 'prio', display: 'Prio', tag: 'input', type: 'text', limit: 10, 'null': false },
|
{ name: 'prio', display: 'Prio', readonly: 1 },
|
||||||
{
|
{
|
||||||
name: 'view::s'
|
name: 'view::s'
|
||||||
display: 'Attributes'
|
display: 'Attributes'
|
||||||
|
@ -146,7 +147,6 @@ class App.Overview extends App.Model
|
||||||
'name',
|
'name',
|
||||||
'link',
|
'link',
|
||||||
'role',
|
'role',
|
||||||
'prio',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@description = '''
|
@description = '''
|
||||||
|
|
|
@ -8,5 +8,6 @@ class Group < ApplicationModel
|
||||||
|
|
||||||
activity_stream_support role: Z_ROLENAME_ADMIN
|
activity_stream_support role: Z_ROLENAME_ADMIN
|
||||||
history_support
|
history_support
|
||||||
|
notify_clients_support
|
||||||
latest_change_support
|
latest_change_support
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,7 @@ class Macro < ApplicationModel
|
||||||
store :perform
|
store :perform
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
notify_clients_support
|
||||||
|
latest_change_support
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,16 +7,18 @@ class Overview < ApplicationModel
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :prio, presence: true
|
validates :prio, presence: true
|
||||||
|
|
||||||
before_create :fill_link
|
before_create :fill_link
|
||||||
before_update :fill_link
|
before_update :fill_link
|
||||||
|
|
||||||
|
notify_clients_support
|
||||||
latest_change_support
|
latest_change_support
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# fill link
|
# fill link
|
||||||
def fill_link
|
def fill_link
|
||||||
return true if link && !link.empty?
|
return true if link.empty?
|
||||||
|
return true if !changes['name']
|
||||||
self.link = name.downcase
|
self.link = name.downcase
|
||||||
link.gsub!(/\s/, '_')
|
link.gsub!(/\s/, '_')
|
||||||
link.gsub!(/[^0-9a-z]/i, '_')
|
link.gsub!(/[^0-9a-z]/i, '_')
|
||||||
|
|
|
@ -5,5 +5,6 @@ class Role < ApplicationModel
|
||||||
has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update
|
has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
activity_stream_support role: Z_ROLENAME_ADMIN
|
activity_stream_support role: Z_ROLENAME_ADMIN
|
||||||
|
notify_clients_support
|
||||||
latest_change_support
|
latest_change_support
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue