From fdbceaf39ea868341dfd69670bc591b337b25cd2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 2 Oct 2014 18:10:52 +0200 Subject: [PATCH] Added generic richtext form attribute. First use in ticket create screen. --- .../_application_controller_form.js.coffee | 8 ++++ .../controllers/agent_ticket_create.js.coffee | 4 +- .../app/views/generic/richtext.jst.eco | 1 + app/assets/stylesheets/zzz.css.erb | 10 +++++ .../20141002000001_update_object_manager4.rb | 43 +++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/app/views/generic/richtext.jst.eco create mode 100644 db/migrate/20141002000001_update_object_manager4.rb diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 37cd19d46..33bfe06c4 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -704,6 +704,14 @@ class App.ControllerForm extends App.Controller else if attribute.tag is 'radio' item = $( App.view('generic/radio')( attribute: attribute ) ) + # richtext + else if attribute.tag is 'richtext' + item = $( App.view('generic/richtext')( attribute: attribute ) ) + item.ce( + mode: attribute.type + maxlength: attribute.maxlength + ) + # textarea else if attribute.tag is 'textarea' fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 ) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index e59537424..f49f276e4 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -272,7 +272,7 @@ class App.TicketCreate extends App.Controller # show text module UI @textModule = new App.WidgetTextModule( - el: @el.find('form').find('textarea') + el: @el.find('[data-name="body"]') ) new Sidebar( @@ -391,7 +391,7 @@ class App.TicketCreate extends App.Controller type: 'success', msg: App.i18n.translateInline( 'Ticket %s created!', @number ), link: "#ticket/zoom/#{@id}" - timeout: 12000, + timeout: 4000, # close ticket create task App.TaskManager.remove( ui.task_key ) diff --git a/app/assets/javascripts/app/views/generic/richtext.jst.eco b/app/assets/javascripts/app/views/generic/richtext.jst.eco new file mode 100644 index 000000000..e9aca481d --- /dev/null +++ b/app/assets/javascripts/app/views/generic/richtext.jst.eco @@ -0,0 +1 @@ +
<%= @attribute.value %>
diff --git a/app/assets/stylesheets/zzz.css.erb b/app/assets/stylesheets/zzz.css.erb index 2bf439bbe..c6d723a33 100644 --- a/app/assets/stylesheets/zzz.css.erb +++ b/app/assets/stylesheets/zzz.css.erb @@ -442,6 +442,10 @@ label { margin-top: 0; } +.form-group .controls { + position: relative; +} + .form-group .help-message { cursor: help; opacity: 0.2; @@ -473,6 +477,12 @@ textarea, box-shadow: 0 0 0 3px hsl(201,62%,90%); } + + .form-control[contenteditable] { + height: auto; + min-height: 100px; + } + .tokenfield.focus { box-shadow: none; border-color: hsl(0,0%,90%); diff --git a/db/migrate/20141002000001_update_object_manager4.rb b/db/migrate/20141002000001_update_object_manager4.rb new file mode 100644 index 000000000..466fd8f1a --- /dev/null +++ b/db/migrate/20141002000001_update_object_manager4.rb @@ -0,0 +1,43 @@ +class UpdateObjectManager4 < ActiveRecord::Migration + def up + + ObjectManager::Attribute.add( + :object => 'TicketArticle', + :name => 'body', + :display => 'Text', + :data_type => 'richtext', + :data_option => { + :type => 'textonly', + :maxlength => 20000, + :upload => true, + :rows => 8, + :null => true, + }, + :editable => false, + :active => true, + :screens => { + :create_top => { + '-all-' => { + :null => false, + }, + }, + :edit => { + :Agent => { + :null => true, + }, + :Customer => { + :null => false, + }, + }, + }, + :pending_migration => false, + :position => 600, + :created_by_id => 1, + :updated_by_id => 1, + ) + + end + + def down + end +end