From a526c47b8ad5676b23d2a5248458290ba1dfbe41 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 11 Feb 2016 00:53:48 +0100 Subject: [PATCH] Moved to richtext for text modules and signatures. --- .../app/controllers/agent_ticket_create.coffee | 4 +--- .../app/controllers/ticket_zoom/article_new.coffee | 5 ++--- .../javascripts/app/lib/base/jquery.textmodule.js | 1 - app/assets/javascripts/app/models/signature.coffee | 2 +- app/assets/javascripts/app/models/text_module.coffee | 2 +- db/migrate/20160211000001_migrate_text_modules.rb | 12 ++++++++++++ db/seeds.rb | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20160211000001_migrate_text_modules.rb diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index 10ea4a90c..b85214ede 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -201,9 +201,7 @@ class App.TicketCreate extends App.Controller type = @$('[name="formSenderType"]').val() if signature isnt undefined && signature.body && type is 'email-out' - signatureFinished = App.Utils.text2html( - App.Utils.replaceTags( signature.body, { user: App.Session.get() } ) - ) + signatureFinished = App.Utils.replaceTags( signature.body, { user: App.Session.get() } ) # get current body body = @$('[data-name="body"]').html() || '' diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index f0381d2cd..1eb9ebb75 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -420,9 +420,8 @@ class App.TicketZoomArticleNew extends App.Controller @$('[data-name=body] [data-signature="true"]').remove() # apply new signature - signatureFinished = App.Utils.text2html( - App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: ticketCurrent } ) - ) + signatureFinished = App.Utils.replaceTags( signature.body, { user: App.Session.get(), ticket: ticketCurrent } ) + body = @$('[data-name=body]').html() || '' if App.Utils.signatureCheck(body, signatureFinished) if !App.Utils.lastLineEmpty(body) diff --git a/app/assets/javascripts/app/lib/base/jquery.textmodule.js b/app/assets/javascripts/app/lib/base/jquery.textmodule.js index 0165f988a..4da286f24 100644 --- a/app/assets/javascripts/app/lib/base/jquery.textmodule.js +++ b/app/assets/javascripts/app/lib/base/jquery.textmodule.js @@ -248,7 +248,6 @@ // paste some content Plugin.prototype.paste = function(string) { - string = App.Utils.text2html(string) if (document.selection) { // IE var range = document.selection.createRange() range.pasteHTML(string) diff --git a/app/assets/javascripts/app/models/signature.coffee b/app/assets/javascripts/app/models/signature.coffee index 88023f79e..b84ee125c 100644 --- a/app/assets/javascripts/app/models/signature.coffee +++ b/app/assets/javascripts/app/models/signature.coffee @@ -5,7 +5,7 @@ class App.Signature extends App.Model @configure_attributes = [ { name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false }, - { name: 'body', display: 'Text', tag: 'textarea', limit: 250, 'null': true, rows: 10 }, + { name: 'body', display: 'Text', tag: 'richtext', limit: 500, 'null': true, rows: 10 }, { name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, 'null': true }, { name: 'active', display: 'Active', tag: 'active', default: true }, { name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 }, diff --git a/app/assets/javascripts/app/models/text_module.coffee b/app/assets/javascripts/app/models/text_module.coffee index 94be8a362..fa25271bc 100644 --- a/app/assets/javascripts/app/models/text_module.coffee +++ b/app/assets/javascripts/app/models/text_module.coffee @@ -5,7 +5,7 @@ class App.TextModule extends App.Model @configure_attributes = [ { name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false }, { name: 'keywords', display: 'Keywords', tag: 'input', type: 'text', limit: 100, null: true }, - { name: 'content', display: 'Content', tag: 'textarea', limit: 250, null: false }, + { name: 'content', display: 'Content', tag: 'richtext', limit: 2000, null: false }, { name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 }, { name: 'active', display: 'Active', tag: 'active', default: true }, ] diff --git a/db/migrate/20160211000001_migrate_text_modules.rb b/db/migrate/20160211000001_migrate_text_modules.rb new file mode 100644 index 000000000..9b2e4d76f --- /dev/null +++ b/db/migrate/20160211000001_migrate_text_modules.rb @@ -0,0 +1,12 @@ +class MigrateTextModules < ActiveRecord::Migration + def up + TextModule.all.each {|text_module| + text_module.content = text_module.content.text2html + text_module.save + } + Signature.all.each {|signature| + signature.body = signature.body.text2html + signature.save + } + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 9aebb7be3..94a497dc9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1516,7 +1516,7 @@ signature = Signature.create_if_not_exists( Super Support - Waterford Business Park 5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA Email: hot@example.com - Web: http://www.example.com/ ---', +--'.text2html, updated_by_id: 1, created_by_id: 1 )