From 1c9105b3f136f2e610ec7cf0c822fc5a4d5d4b86 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 28 Sep 2015 14:01:40 +0200 Subject: [PATCH] Fixed order of ticket attributes after overview update. --- .../app/controllers/ticket_overview.js.coffee | 131 +++++------------- .../javascripts/app/models/ticket.js.coffee | 4 +- 2 files changed, 36 insertions(+), 99 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee index 04104148f..13d38b69d 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.js.coffee @@ -523,11 +523,11 @@ class App.OverviewSettings extends App.ControllerModal @configure_attributes_article = [] if @view_mode is 'd' @configure_attributes_article.push({ - name: 'view::per_page', - display: 'Items per page', - tag: 'select', - multiple: false, - null: false, + name: 'view::per_page' + display: 'Items per page' + tag: 'select' + multiple: false + null: false default: @overview.view.per_page options: { 5: ' 5' @@ -536,8 +536,32 @@ class App.OverviewSettings extends App.ControllerModal 20: '20' 25: '25' }, - class: 'medium', }) + attributeOptions = {} + attributeOptionsArray = [] + configure_attributes = App.Ticket.configure_attributes + for row, attribute of App.Ticket.attributesGet() + configure_attributes.push attribute + for row in configure_attributes + + # ignore passwords + if row.type isnt 'password' + name = row.name + + # get correct data name + if row.name.substr(row.name.length-4,4) is '_ids' + name = row.name.substr(0, row.name.length-4) + else if row.name.substr(row.name.length-3,3) is '_id' + name = row.name.substr(0, row.name.length-3) + + if !attributeOptions[ name ] + attributeOptions[ name ] = row.display + attributeOptionsArray.push( + { + value: name + name: row.display + } + ) @configure_attributes_article.push({ name: "view::#{@view_mode}" display: 'Attributes' @@ -545,77 +569,8 @@ class App.OverviewSettings extends App.ControllerModal default: @overview.view[@view_mode] null: false translate: true - options: [ - { - value: 'number' - name: 'Number' - }, - { - value: 'title' - name: 'Title' - }, - { - value: 'customer' - name: 'Customer' - }, - { - value: 'organization' - name: 'Organization' - }, - { - value: 'state' - name: 'State' - }, - { - value: 'priority' - name: 'Priority' - }, - { - value: 'group' - name: 'Group' - }, - { - value: 'owner' - name: 'Owner' - }, - { - value: 'created_at' - name: 'Age' - }, - { - value: 'last_contact' - name: 'Last Contact Time' - }, - { - value: 'last_contact_agent' - name: 'Last Contact Agent Time' - }, - { - value: 'last_contact_customer' - name: 'Last Contact Customer Time' - }, - { - value: 'first_response' - name: 'First Response Time' - }, - { - value: 'close_time' - name: 'Close Time' - }, - { - value: 'escalation_time' - name: 'Escalation Time' - }, - { - value: 'pending_time' - name: 'Pending Reminder Time' - }, - { - value: 'article_count' - name: 'Article Count' - }, - ] - class: 'medium' + sortBy: null + options: attributeOptionsArray }, { name: 'order::by' @@ -624,24 +579,8 @@ class App.OverviewSettings extends App.ControllerModal default: @overview.order.by null: false translate: true - options: - number: 'Number' - title: 'Title' - customer: 'Customer' - organization: 'Organization' - state: 'State' - priority: 'Priority' - group: 'Group' - owner: 'Owner' - created_at: 'Age' - last_contact: 'Last Contact' - last_contact_agent: 'Last Contact Agent' - last_contact_customer: 'Last Contact Customer' - first_response: 'First Response' - close_time: 'Close Time' - escalation_time: 'Escalation' - article_count: 'Article Count' - class: 'medium' + sortBy: null + options: attributeOptionsArray }, { name: 'order::direction' @@ -653,7 +592,6 @@ class App.OverviewSettings extends App.ControllerModal options: ASC: 'up' DESC: 'down' - class: 'medium' }, { name: 'group_by' @@ -670,7 +608,6 @@ class App.OverviewSettings extends App.ControllerModal priority: 'Priority' group: 'Group' owner: 'Owner' - class: 'medium' }) @head = App.i18n.translateContent( 'Edit' ) + ': ' + App.i18n.translateContent( @overview.name ) diff --git a/app/assets/javascripts/app/models/ticket.js.coffee b/app/assets/javascripts/app/models/ticket.js.coffee index c1ab262a1..985868aef 100644 --- a/app/assets/javascripts/app/models/ticket.js.coffee +++ b/app/assets/javascripts/app/models/ticket.js.coffee @@ -4,12 +4,13 @@ class App.Ticket extends App.Model @url: @apiPath + '/tickets' @configure_attributes = [ { name: 'number', display: '#', tag: 'input', type: 'text', limit: 100, null: true, read_only: true, style: 'width: 68px' }, + { name: 'title', display: 'Title', tag: 'input', type: 'text', limit: 100, null: false, parentClass: 'noTruncate' }, { name: 'customer_id', display: 'Customer', tag: 'input', type: 'text', limit: 100, null: false, autocapitalize: false, relation: 'User' }, { name: 'organization_id', display: 'Organization', tag: 'select', relation: 'Organization', tagreadonly: 1 }, { name: 'group_id', display: 'Group', tag: 'select', multiple: false, limit: 100, null: false, relation: 'Group', style: 'width: 10%', edit: true }, { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, limit: 100, null: true, relation: 'User', style: 'width: 12%', edit: true }, - { name: 'title', display: 'Title', tag: 'input', type: 'text', limit: 100, null: false, parentClass: 'noTruncate' }, { name: 'state_id', display: 'State', tag: 'select', multiple: false, null: false, relation: 'TicketState', default: 'new', style: 'width: 12%', edit: true, customer: true, }, + { name: 'pending_time', display: 'Pending Time', tag: 'datetime', null: true, style: 'width: 12%', parentClass: 'noTruncate' }, { name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', default: '2 normal', style: 'width: 12%', edit: true, customer: true, }, { name: 'article_count', display: 'Article#', style: 'width: 12%' }, { name: 'escalation_time', display: 'Escalation', tag: 'datetime', null: true, style: 'width: 12%', class: 'escalation', parentClass: 'noTruncate' }, @@ -18,7 +19,6 @@ class App.Ticket extends App.Model { name: 'last_contact_customer', display: 'Last contact (Customer)', tag: 'datetime', null: true, style: 'width: 12%', parentClass: 'noTruncate' }, { name: 'first_response', display: 'First response', tag: 'datetime', null: true, style: 'width: 12%', parentClass: 'noTruncate' }, { name: 'close_time', display: 'Close time', tag: 'datetime', null: true, style: 'width: 12%', parentClass: 'noTruncate' }, - { name: 'pending_time', display: 'Pending Time', tag: 'datetime', null: true, style: 'width: 12%', parentClass: 'noTruncate' }, { name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 }, { name: 'created_at', display: 'Created at', tag: 'datetime', style: 'width: 120px', readonly: 1, parentClass: 'noTruncate' }, { name: 'updated_by_id', display: 'Updated by', relation: 'User', readonly: 1 },