Browse Source

Fixes #4530 - Create new organization - pasting text in note field not possible

Mantas Masalskis 1 year ago
parent
commit
90b7e23211

+ 2 - 3
app/assets/javascripts/app/lib/base/jquery.contenteditable.js

@@ -341,12 +341,11 @@
     htmlRaw = this.getHtmlFromClipboard(clipboardData)
 
     if (!App.Utils.clipboardHtmlIsWithText(htmlRaw)) {
-      // stop processing if input form does not accept images
-      if(this.options.noImages) return;
-
       // insert and in case, resize images
       clipboardImage = this.getClipboardDataImage(clipboardData)
       if (clipboardImage) {
+        // stop processing if input form does not accept images
+        if(this.options.noImages) return;
 
         this.log('paste image', clipboardImage)
 

+ 24 - 0
db/migrate/20230808070608_issue_4530_notes_sans_images.rb

@@ -0,0 +1,24 @@
+# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
+
+class Issue4530NotesSansImages < ActiveRecord::Migration[6.1]
+  def up
+    # return if it's a new setup
+    return if !Setting.exists?(name: 'system_init_done')
+
+    # This was already migrated Issue4050ImageInNote migration
+    # However, new installations were created with a wrong seed value
+    # Seed values are now changed
+    # Rerunning this migration to set correct values
+    # In systems set up in between previous migration and the seed files fix
+
+    [User, Organization, Group].each do |klass|
+      note_attr = ObjectManager::Attribute.for_object(klass).find_by(name: :note)
+
+      next if note_attr.blank?
+      next if note_attr.data_option[:no_images] == true
+
+      note_attr.data_option[:no_images] = true
+      note_attr.save!
+    end
+  end
+end

+ 3 - 3
db/seeds/object_manager_attributes.rb

@@ -1300,7 +1300,7 @@ ObjectManager::Attribute.add(
   data_option: {
     type:      'text',
     maxlength: 5000,
-    no_images: false,
+    no_images: true,
     null:      true,
     note:      __('Notes are visible to agents only, never to customers.'),
   },
@@ -1642,7 +1642,7 @@ ObjectManager::Attribute.add(
   data_option: {
     type:      'text',
     maxlength: 5000,
-    no_images: false,
+    no_images: true,
     null:      true,
     note:      __('Notes are visible to agents only, never to customers.'),
   },
@@ -1997,7 +1997,7 @@ ObjectManager::Attribute.add(
   data_option: {
     type:      'text',
     maxlength: 250,
-    no_images: false,
+    no_images: true,
     null:      true,
     note:      __('Notes are visible to agents only, never to customers.'),
   },

+ 2 - 2
spec/graphql/gql/queries/object_manager/frontend_attributes_spec.rb

@@ -200,7 +200,7 @@ RSpec.describe Gql::Queries::ObjectManager::FrontendAttributes, type: :graphql d
               'dataType'   => 'richtext',
               'dataOption' => { 'type'      => 'text',
                                 'maxlength' => 5000,
-                                'no_images' => false,
+                                'no_images' => true,
                                 'null'      => true,
                                 'note'      => 'Notes are visible to agents only, never to customers.' },
               'isInternal' => true,
@@ -264,7 +264,7 @@ RSpec.describe Gql::Queries::ObjectManager::FrontendAttributes, type: :graphql d
               'dataType'   => 'richtext',
               'dataOption' => { 'type'      => 'text',
                                 'maxlength' => 5000,
-                                'no_images' => false,
+                                'no_images' => true,
                                 'null'      => true,
                                 'note'      => 'Notes are visible to agents only, never to customers.' },
               'isInternal' => true,