katalyst-koi 5.0.0.alpha.2 → 5.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/builds/katalyst/koi.esm.js +832 -0
- data/app/assets/builds/katalyst/koi.js +832 -0
- data/app/assets/builds/katalyst/koi.min.js +2 -0
- data/app/assets/builds/katalyst/koi.min.js.map +1 -0
- data/app/assets/config/koi.js +0 -12
- data/app/assets/stylesheets/koi/blocks/modal.css +4 -1
- data/app/assets/stylesheets/koi/blocks/tables/query.css +5 -4
- data/app/assets/stylesheets/koi/blocks/tables/table.css +21 -20
- data/app/assets/stylesheets/koi/forms/combobox.css +81 -0
- data/app/assets/stylesheets/koi/forms/index.css +3 -0
- data/app/assets/stylesheets/koi/forms/input.css +8 -7
- data/app/assets/stylesheets/koi/forms/textarea.css +6 -0
- data/app/assets/stylesheets/koi/forms/trix.css +6 -2
- data/app/components/koi/pagy_nav_component.rb +7 -0
- data/app/controllers/concerns/koi/controller/has_attachments.rb +1 -1
- data/app/controllers/concerns/koi/controller.rb +2 -0
- data/app/helpers/koi/modal_helper.rb +15 -13
- data/app/{assets/javascripts/koi/admin.js → javascript/koi/application.js} +2 -2
- data/app/{assets/javascripts → javascript}/koi/controllers/form_request_submit_controller.js +1 -1
- data/app/javascript/koi/controllers/index.js +89 -0
- data/app/{assets/javascripts/koi/controllers/koi → javascript/koi/controllers}/modal_controller.js +1 -1
- data/app/{assets/javascripts → javascript}/koi/controllers/show_hide_controller.js +1 -1
- data/app/javascript/koi/elements/index.js +1 -0
- data/app/models/admin/user.rb +2 -2
- data/app/models/concerns/koi/model/archivable.rb +3 -3
- data/app/views/layouts/koi/application.html.erb +1 -1
- data/config/importmap.rb +1 -3
- data/lib/generators/koi/helpers/attribute_helpers.rb +11 -8
- data/lib/generators/koi/helpers/resource_helpers.rb +9 -1
- data/lib/koi/config.rb +2 -0
- data/lib/koi/engine.rb +10 -7
- data/lib/koi/form_builder.rb +0 -1
- data/lib/koi.rb +0 -7
- metadata +27 -37
- data/app/assets/javascripts/koi/controllers/document_field_controller.js +0 -26
- data/app/assets/javascripts/koi/controllers/file_field_controller.js +0 -152
- data/app/assets/javascripts/koi/controllers/image_field_controller.js +0 -24
- data/app/assets/javascripts/koi/controllers/index.js +0 -15
- data/app/assets/javascripts/koi/elements/index.js +0 -1
- data/app/mailers/koi/application_mailer.rb +0 -8
- data/app/views/katalyst/content/asides/_aside.html+form.erb +0 -6
- data/app/views/katalyst/content/columns/_column.html+form.erb +0 -5
- data/app/views/katalyst/content/contents/_content.html+form.erb +0 -8
- data/app/views/katalyst/content/figures/_figure.html+form.erb +0 -9
- data/app/views/katalyst/content/groups/_group.html+form.erb +0 -5
- data/app/views/katalyst/content/items/_item.html+form.erb +0 -5
- data/app/views/katalyst/content/sections/_section.html+form.erb +0 -5
- data/app/views/katalyst/content/tables/_table.html+form.erb +0 -36
- data/lib/koi/form/elements/document.rb +0 -47
- data/lib/koi/form/elements/file_element.rb +0 -128
- data/lib/koi/form/elements/image.rb +0 -44
- data/lib/koi/form/govuk_extensions.rb +0 -73
- /data/app/{assets/javascripts → javascript}/koi/controllers/application.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/clipboard_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/flash_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/index_actions_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/keyboard_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/navigation_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/navigation_toggle_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/pagy_nav_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/sluggable_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_authentication_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/controllers/webauthn_registration_controller.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/elements/toolbar.js +0 -0
- /data/app/{assets/javascripts → javascript}/koi/utils/transition.js +0 -0
- /data/lib/{katalyst/koi.rb → katalyst-koi.rb} +0 -0
@@ -24,11 +24,11 @@ module Koi
|
|
24
24
|
|
25
25
|
default_scope { not_archived }
|
26
26
|
|
27
|
-
alias_method :archived
|
27
|
+
alias_method :archived, :archived?
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
31
|
-
def archived
|
30
|
+
# @return true if the record has been archived.
|
31
|
+
def archived?
|
32
32
|
archived_at.present?
|
33
33
|
end
|
34
34
|
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<%= stylesheet_link_tag Koi.config.admin_stylesheet, "data-turbo-track": "reload" %>
|
22
22
|
|
23
23
|
<!-- SCRIPTS -->
|
24
|
-
<%= javascript_importmap_tags
|
24
|
+
<%= javascript_importmap_tags Koi.config.admin_javascript_entry_point %>
|
25
25
|
</head>
|
26
26
|
<body data-controller="keyboard"
|
27
27
|
data-action="keyup->keyboard#event"
|
data/config/importmap.rb
CHANGED
@@ -4,8 +4,6 @@ pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
|
4
4
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
5
5
|
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
|
6
6
|
pin "@github/webauthn-json/browser-ponyfill", to: "https://ga.jspm.io/npm:@github/webauthn-json@2.1.1/dist/esm/webauthn-json.browser-ponyfill.js"
|
7
|
+
pin "@katalyst/koi", to: "katalyst/koi.min.js"
|
7
8
|
pin "@rails/actiontext", to: "actiontext.js", preload: true
|
8
9
|
pin "trix"
|
9
|
-
|
10
|
-
pin_all_from Koi::Engine.root.join("app/assets/javascripts/koi"),
|
11
|
-
under: "koi", preload: Rails.env.test?
|
@@ -8,6 +8,17 @@ module Koi
|
|
8
8
|
module Helpers
|
9
9
|
module AttributeHelpers
|
10
10
|
extend ActiveSupport::Concern
|
11
|
+
included do
|
12
|
+
private
|
13
|
+
|
14
|
+
def parse_attributes!
|
15
|
+
if attributes.none? && model_class && model_class < ActiveRecord::Base
|
16
|
+
load_attributes!
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
11
22
|
|
12
23
|
class IntrospectedAttribute < Rails::Generators::GeneratedAttribute
|
13
24
|
attr_reader :association, :attachment, :enum
|
@@ -33,12 +44,6 @@ module Koi
|
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
36
|
-
def initialize(args, *options)
|
37
|
-
super
|
38
|
-
|
39
|
-
load_attributes! if attributes.empty?
|
40
|
-
end
|
41
|
-
|
42
47
|
def govuk_input_for(attribute)
|
43
48
|
AttributeTypes.for(attribute).govuk_input
|
44
49
|
end
|
@@ -80,8 +85,6 @@ module Koi
|
|
80
85
|
end
|
81
86
|
|
82
87
|
def load_attributes!
|
83
|
-
return unless model_class && model_class < ActiveRecord::Base
|
84
|
-
|
85
88
|
load_basic_attributes!
|
86
89
|
load_attachment_attributes!
|
87
90
|
load_rich_text_attributes!
|
@@ -17,9 +17,17 @@ module Koi
|
|
17
17
|
@controller_class_path = ["admin", *@controller_class_path]
|
18
18
|
end
|
19
19
|
|
20
|
+
def controller_class_path
|
21
|
+
if options[:model_name] || @controller_class_path
|
22
|
+
@controller_class_path
|
23
|
+
else
|
24
|
+
class_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
def class_name
|
21
29
|
candidate = (class_path + [file_name]).map!(&:camelize).join("::")
|
22
|
-
if class_path_overlap.any?
|
30
|
+
if @controller_class_path && class_path_overlap.any?
|
23
31
|
"::#{candidate}"
|
24
32
|
else
|
25
33
|
candidate
|
data/lib/koi/config.rb
CHANGED
@@ -15,6 +15,8 @@ module Koi
|
|
15
15
|
|
16
16
|
config_accessor(:admin_stylesheet) { "admin" }
|
17
17
|
|
18
|
+
config_accessor(:admin_javascript_entry_point) { "@katalyst/koi" }
|
19
|
+
|
18
20
|
config_accessor(:document_mime_types) do
|
19
21
|
%w[image/png image/gif image/jpeg image/webp application/pdf audio/*].freeze
|
20
22
|
end
|
data/lib/koi/engine.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "importmap-rails"
|
4
4
|
require "katalyst/content"
|
5
|
-
require "katalyst
|
5
|
+
require "katalyst-govuk-formbuilder"
|
6
6
|
require "katalyst/navigation"
|
7
7
|
require "katalyst/tables"
|
8
8
|
require "pagy"
|
@@ -15,6 +15,7 @@ require "webauthn"
|
|
15
15
|
module Koi
|
16
16
|
class Engine < ::Rails::Engine
|
17
17
|
engine_name "koi"
|
18
|
+
isolate_namespace Koi
|
18
19
|
config.eager_load_namespaces << Koi
|
19
20
|
config.paths.add("lib", autoload_once: true, exclude: %w[lib/generators lib/tasks])
|
20
21
|
|
@@ -24,10 +25,16 @@ module Koi
|
|
24
25
|
g.factory_bot dir: "spec/factories"
|
25
26
|
end
|
26
27
|
|
28
|
+
initializer "koi.autoload", before: :setup_once_autoloader do
|
29
|
+
%w[lib/katalyst-koi.rb lib/generators lib/tasks].each do |path|
|
30
|
+
Rails.autoloaders.once.ignore File.expand_path(root.join(path))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
initializer "koi.assets" do |app|
|
28
35
|
app.config.after_initialize do |_|
|
29
36
|
if app.config.respond_to?(:assets)
|
30
|
-
app.config.assets.precompile += %w(koi.js)
|
37
|
+
app.config.assets.precompile += %w(katalyst/koi.js)
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -41,13 +48,9 @@ module Koi
|
|
41
48
|
FactoryBot.definition_file_paths << root.join("spec/factories") if defined?(FactoryBot)
|
42
49
|
end
|
43
50
|
|
44
|
-
initializer "koi.forms" do
|
45
|
-
GOVUKDesignSystemFormBuilder::Builder.include(Koi::Form::GOVUKExtensions)
|
46
|
-
end
|
47
|
-
|
48
51
|
initializer "koi.importmap", before: "importmap" do |app|
|
49
52
|
app.config.importmap.paths << root.join("config/importmap.rb")
|
50
|
-
app.config.importmap.cache_sweepers << root.join("app/assets/
|
53
|
+
app.config.importmap.cache_sweepers << root.join("app/assets/builds")
|
51
54
|
end
|
52
55
|
|
53
56
|
initializer "koi.middleware" do |app|
|
data/lib/koi/form_builder.rb
CHANGED
data/lib/koi.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-koi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.
|
4
|
+
version: 5.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
@@ -228,6 +228,10 @@ files:
|
|
228
228
|
- MIT-LICENSE
|
229
229
|
- README.md
|
230
230
|
- Upgrade.md
|
231
|
+
- app/assets/builds/katalyst/koi.esm.js
|
232
|
+
- app/assets/builds/katalyst/koi.js
|
233
|
+
- app/assets/builds/katalyst/koi.min.js
|
234
|
+
- app/assets/builds/katalyst/koi.min.js.map
|
231
235
|
- app/assets/config/koi.js
|
232
236
|
- app/assets/images/koi/application/chevron-right.svg
|
233
237
|
- app/assets/images/koi/application/glyphicons-halflings-white.png
|
@@ -260,28 +264,6 @@ files:
|
|
260
264
|
- app/assets/images/koi/icons/add.svg
|
261
265
|
- app/assets/images/koi/icons/close.svg
|
262
266
|
- app/assets/images/koi/koi.png
|
263
|
-
- app/assets/javascripts/koi/admin.js
|
264
|
-
- app/assets/javascripts/koi/controllers/application.js
|
265
|
-
- app/assets/javascripts/koi/controllers/clipboard_controller.js
|
266
|
-
- app/assets/javascripts/koi/controllers/document_field_controller.js
|
267
|
-
- app/assets/javascripts/koi/controllers/file_field_controller.js
|
268
|
-
- app/assets/javascripts/koi/controllers/flash_controller.js
|
269
|
-
- app/assets/javascripts/koi/controllers/form_request_submit_controller.js
|
270
|
-
- app/assets/javascripts/koi/controllers/image_field_controller.js
|
271
|
-
- app/assets/javascripts/koi/controllers/index.js
|
272
|
-
- app/assets/javascripts/koi/controllers/index_actions_controller.js
|
273
|
-
- app/assets/javascripts/koi/controllers/keyboard_controller.js
|
274
|
-
- app/assets/javascripts/koi/controllers/koi/modal_controller.js
|
275
|
-
- app/assets/javascripts/koi/controllers/navigation_controller.js
|
276
|
-
- app/assets/javascripts/koi/controllers/navigation_toggle_controller.js
|
277
|
-
- app/assets/javascripts/koi/controllers/pagy_nav_controller.js
|
278
|
-
- app/assets/javascripts/koi/controllers/show_hide_controller.js
|
279
|
-
- app/assets/javascripts/koi/controllers/sluggable_controller.js
|
280
|
-
- app/assets/javascripts/koi/controllers/webauthn_authentication_controller.js
|
281
|
-
- app/assets/javascripts/koi/controllers/webauthn_registration_controller.js
|
282
|
-
- app/assets/javascripts/koi/elements/index.js
|
283
|
-
- app/assets/javascripts/koi/elements/toolbar.js
|
284
|
-
- app/assets/javascripts/koi/utils/transition.js
|
285
267
|
- app/assets/stylesheets/koi/blocks/actions.css
|
286
268
|
- app/assets/stylesheets/koi/blocks/application-header.css
|
287
269
|
- app/assets/stylesheets/koi/blocks/application-navigation.css
|
@@ -307,6 +289,7 @@ files:
|
|
307
289
|
- app/assets/stylesheets/koi/compositions/wrapper.css
|
308
290
|
- app/assets/stylesheets/koi/forms/caption.css
|
309
291
|
- app/assets/stylesheets/koi/forms/checkboxes.css
|
292
|
+
- app/assets/stylesheets/koi/forms/combobox.css
|
310
293
|
- app/assets/stylesheets/koi/forms/date-input.css
|
311
294
|
- app/assets/stylesheets/koi/forms/document-field.css
|
312
295
|
- app/assets/stylesheets/koi/forms/errors.css
|
@@ -343,6 +326,7 @@ files:
|
|
343
326
|
- app/components/koi/header_component.rb
|
344
327
|
- app/components/koi/navigation/editor/errors_component.html.erb
|
345
328
|
- app/components/koi/navigation/editor/errors_component.rb
|
329
|
+
- app/components/koi/pagy_nav_component.rb
|
346
330
|
- app/components/koi/summary_table_component.rb
|
347
331
|
- app/components/koi/table_component.rb
|
348
332
|
- app/components/koi/table_query_component.rb
|
@@ -370,8 +354,26 @@ files:
|
|
370
354
|
- app/helpers/koi/index_actions_helper.rb
|
371
355
|
- app/helpers/koi/modal_helper.rb
|
372
356
|
- app/helpers/koi/pagy.rb
|
357
|
+
- app/javascript/koi/application.js
|
358
|
+
- app/javascript/koi/controllers/application.js
|
359
|
+
- app/javascript/koi/controllers/clipboard_controller.js
|
360
|
+
- app/javascript/koi/controllers/flash_controller.js
|
361
|
+
- app/javascript/koi/controllers/form_request_submit_controller.js
|
362
|
+
- app/javascript/koi/controllers/index.js
|
363
|
+
- app/javascript/koi/controllers/index_actions_controller.js
|
364
|
+
- app/javascript/koi/controllers/keyboard_controller.js
|
365
|
+
- app/javascript/koi/controllers/modal_controller.js
|
366
|
+
- app/javascript/koi/controllers/navigation_controller.js
|
367
|
+
- app/javascript/koi/controllers/navigation_toggle_controller.js
|
368
|
+
- app/javascript/koi/controllers/pagy_nav_controller.js
|
369
|
+
- app/javascript/koi/controllers/show_hide_controller.js
|
370
|
+
- app/javascript/koi/controllers/sluggable_controller.js
|
371
|
+
- app/javascript/koi/controllers/webauthn_authentication_controller.js
|
372
|
+
- app/javascript/koi/controllers/webauthn_registration_controller.js
|
373
|
+
- app/javascript/koi/elements/index.js
|
374
|
+
- app/javascript/koi/elements/toolbar.js
|
375
|
+
- app/javascript/koi/utils/transition.js
|
373
376
|
- app/jobs/koi/application_job.rb
|
374
|
-
- app/mailers/koi/application_mailer.rb
|
375
377
|
- app/models/admin/collection.rb
|
376
378
|
- app/models/admin/credential.rb
|
377
379
|
- app/models/admin/user.rb
|
@@ -417,14 +419,6 @@ files:
|
|
417
419
|
- app/views/admin/well_knowns/index.html.erb
|
418
420
|
- app/views/admin/well_knowns/new.html.erb
|
419
421
|
- app/views/admin/well_knowns/show.html.erb
|
420
|
-
- app/views/katalyst/content/asides/_aside.html+form.erb
|
421
|
-
- app/views/katalyst/content/columns/_column.html+form.erb
|
422
|
-
- app/views/katalyst/content/contents/_content.html+form.erb
|
423
|
-
- app/views/katalyst/content/figures/_figure.html+form.erb
|
424
|
-
- app/views/katalyst/content/groups/_group.html+form.erb
|
425
|
-
- app/views/katalyst/content/items/_item.html+form.erb
|
426
|
-
- app/views/katalyst/content/sections/_section.html+form.erb
|
427
|
-
- app/views/katalyst/content/tables/_table.html+form.erb
|
428
422
|
- app/views/katalyst/navigation/items/_button.html.erb
|
429
423
|
- app/views/katalyst/navigation/items/_heading.html.erb
|
430
424
|
- app/views/katalyst/navigation/items/_link.html.erb
|
@@ -478,7 +472,7 @@ files:
|
|
478
472
|
- lib/generators/koi/helpers/attribute_types.rb
|
479
473
|
- lib/generators/koi/helpers/resource_helpers.rb
|
480
474
|
- lib/generators/koi/model/model_generator.rb
|
481
|
-
- lib/katalyst
|
475
|
+
- lib/katalyst-koi.rb
|
482
476
|
- lib/koi.rb
|
483
477
|
- lib/koi/caching.rb
|
484
478
|
- lib/koi/config.rb
|
@@ -486,10 +480,6 @@ files:
|
|
486
480
|
- lib/koi/extensions/object_rendering.rb
|
487
481
|
- lib/koi/form/builder.rb
|
488
482
|
- lib/koi/form/content.rb
|
489
|
-
- lib/koi/form/elements/document.rb
|
490
|
-
- lib/koi/form/elements/file_element.rb
|
491
|
-
- lib/koi/form/elements/image.rb
|
492
|
-
- lib/koi/form/govuk_extensions.rb
|
493
483
|
- lib/koi/form_builder.rb
|
494
484
|
- lib/koi/menu.rb
|
495
485
|
- lib/koi/menu/builder.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import FileFieldController from "koi/controllers/file_field_controller";
|
2
|
-
|
3
|
-
export default class DocumentFieldController extends FileFieldController {
|
4
|
-
connect() {
|
5
|
-
this.initialPreviewContent = this.filenameTag.text;
|
6
|
-
}
|
7
|
-
|
8
|
-
setPreviewContent(content) {
|
9
|
-
this.filenameTag.innerText = content;
|
10
|
-
}
|
11
|
-
|
12
|
-
showPreview(file) {
|
13
|
-
const reader = new FileReader();
|
14
|
-
|
15
|
-
reader.onload = (e) => {
|
16
|
-
if (this.filenameTag) {
|
17
|
-
this.filenameTag.innerText = file.name;
|
18
|
-
}
|
19
|
-
};
|
20
|
-
reader.readAsDataURL(file);
|
21
|
-
}
|
22
|
-
|
23
|
-
get filenameTag() {
|
24
|
-
return this.previewTarget.querySelector("p.preview-filename");
|
25
|
-
}
|
26
|
-
}
|
@@ -1,152 +0,0 @@
|
|
1
|
-
import { Controller } from "@hotwired/stimulus";
|
2
|
-
|
3
|
-
export default class FileFieldController extends Controller {
|
4
|
-
static targets = ["preview", "destroy"];
|
5
|
-
static values = {
|
6
|
-
mimeTypes: Array,
|
7
|
-
};
|
8
|
-
|
9
|
-
connect() {
|
10
|
-
this.counter = 0;
|
11
|
-
this.initialPreviewContent = null;
|
12
|
-
this.onUploadFlag = false;
|
13
|
-
}
|
14
|
-
|
15
|
-
onUpload(event) {
|
16
|
-
this.onUploadFlag = true;
|
17
|
-
|
18
|
-
// Set the file to be destroyed only if it is already persisted
|
19
|
-
if (this.hasDestroyTarget) {
|
20
|
-
this.destroyTarget.value = false;
|
21
|
-
}
|
22
|
-
this.previewTarget.removeAttribute("hidden");
|
23
|
-
|
24
|
-
// Show preview only if a file has been selected in the file picker popup. If cancelled, show previous file or do
|
25
|
-
// not show preview at all
|
26
|
-
if (this.hasPreviewTarget) {
|
27
|
-
if (event.currentTarget.files.length > 0) {
|
28
|
-
this.showPreview(event.currentTarget.files[0]);
|
29
|
-
} else {
|
30
|
-
this.setPreviewContent(this.initialPreviewContent);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
setDestroy(event) {
|
36
|
-
event.preventDefault();
|
37
|
-
|
38
|
-
// If the data is already persisted and another image has been picked from the file picker popup, but the new image
|
39
|
-
// is removed, show the original image
|
40
|
-
if (this.initialPreviewContent && this.onUploadFlag) {
|
41
|
-
this.onUploadFlag = false;
|
42
|
-
this.setPreviewContent(this.initialPreviewContent);
|
43
|
-
} else {
|
44
|
-
// Set image to be destroyed, hide preview and remove image url
|
45
|
-
if (this.hasDestroyTarget) {
|
46
|
-
this.destroyTarget.value = true;
|
47
|
-
}
|
48
|
-
if (this.hasPreviewTarget) {
|
49
|
-
this.previewTarget.setAttribute("hidden", "");
|
50
|
-
this.setPreviewContent("");
|
51
|
-
}
|
52
|
-
if (this.previousInput) {
|
53
|
-
this.previousInput.toggleAttribute("disabled", true);
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
this.fileInput.value = "";
|
58
|
-
}
|
59
|
-
|
60
|
-
setPreviewContent(content) {
|
61
|
-
if (this.filenameTag) {
|
62
|
-
this.filenameTag.innerText = text;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
drop(event) {
|
67
|
-
event.preventDefault();
|
68
|
-
|
69
|
-
const file = this.fileForEvent(event, this.mimeTypesValue);
|
70
|
-
if (file) {
|
71
|
-
const dT = new DataTransfer();
|
72
|
-
dT.items.add(file);
|
73
|
-
this.fileInput.files = dT.files;
|
74
|
-
this.fileInput.dispatchEvent(new Event("change"));
|
75
|
-
}
|
76
|
-
|
77
|
-
this.counter = 0;
|
78
|
-
this.element.classList.remove("droppable");
|
79
|
-
}
|
80
|
-
|
81
|
-
dragover(event) {
|
82
|
-
event.preventDefault();
|
83
|
-
}
|
84
|
-
|
85
|
-
dragenter(event) {
|
86
|
-
event.preventDefault();
|
87
|
-
|
88
|
-
if (this.counter === 0) {
|
89
|
-
this.element.classList.add("droppable");
|
90
|
-
}
|
91
|
-
this.counter++;
|
92
|
-
}
|
93
|
-
|
94
|
-
dragleave(event) {
|
95
|
-
event.preventDefault();
|
96
|
-
|
97
|
-
this.counter--;
|
98
|
-
if (this.counter === 0) {
|
99
|
-
this.element.classList.remove("droppable");
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
get fileInput() {
|
104
|
-
return this.element.querySelector("input[type='file']");
|
105
|
-
}
|
106
|
-
|
107
|
-
get previousInput() {
|
108
|
-
return this.element.querySelector(
|
109
|
-
`input[type='hidden'][name='${this.fileInput.name}']`,
|
110
|
-
);
|
111
|
-
}
|
112
|
-
|
113
|
-
get filenameTag() {
|
114
|
-
if (!this.hasPreviewTarget) return null;
|
115
|
-
|
116
|
-
return this.previewTarget.querySelector("p.preview-filename");
|
117
|
-
}
|
118
|
-
|
119
|
-
showPreview(file) {
|
120
|
-
const reader = new FileReader();
|
121
|
-
|
122
|
-
reader.onload = (e) => {
|
123
|
-
if (this.filenameTag) {
|
124
|
-
this.filenameTag.innerText = file.name;
|
125
|
-
}
|
126
|
-
};
|
127
|
-
reader.readAsDataURL(file);
|
128
|
-
}
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Given a drop event, find the first acceptable file.
|
132
|
-
* @param event {DropEvent}
|
133
|
-
* @param mimeTypes {String[]}
|
134
|
-
* @returns {File}
|
135
|
-
*/
|
136
|
-
fileForEvent(event, mimeTypes) {
|
137
|
-
const accept = (file) => mimeTypes.indexOf(file.type) > -1;
|
138
|
-
|
139
|
-
let file;
|
140
|
-
|
141
|
-
if (event.dataTransfer.items) {
|
142
|
-
const item = [...event.dataTransfer.items].find(accept);
|
143
|
-
if (item) {
|
144
|
-
file = item.getAsFile();
|
145
|
-
}
|
146
|
-
} else {
|
147
|
-
file = [...event.dataTransfer.files].find(accept);
|
148
|
-
}
|
149
|
-
|
150
|
-
return file;
|
151
|
-
}
|
152
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import FileFieldController from "koi/controllers/file_field_controller";
|
2
|
-
|
3
|
-
export default class ImageFieldController extends FileFieldController {
|
4
|
-
connect() {
|
5
|
-
this.initialPreviewContent = this.imageTag.getAttribute("src");
|
6
|
-
}
|
7
|
-
|
8
|
-
setPreviewContent(content) {
|
9
|
-
this.imageTag.src = content;
|
10
|
-
}
|
11
|
-
|
12
|
-
showPreview(file) {
|
13
|
-
const reader = new FileReader();
|
14
|
-
|
15
|
-
reader.onload = (e) => {
|
16
|
-
this.imageTag.src = e.target.result;
|
17
|
-
};
|
18
|
-
reader.readAsDataURL(file);
|
19
|
-
}
|
20
|
-
|
21
|
-
get imageTag() {
|
22
|
-
return this.previewTarget.querySelector("img");
|
23
|
-
}
|
24
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { application } from "koi/controllers/application";
|
2
|
-
|
3
|
-
import content from "@katalyst/content";
|
4
|
-
application.load(content);
|
5
|
-
|
6
|
-
import navigation from "@katalyst/navigation";
|
7
|
-
application.load(navigation);
|
8
|
-
|
9
|
-
import tables from "@katalyst/tables";
|
10
|
-
application.load(tables);
|
11
|
-
|
12
|
-
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
13
|
-
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading";
|
14
|
-
eagerLoadControllersFrom("controllers", application);
|
15
|
-
eagerLoadControllersFrom("koi/controllers", application);
|
@@ -1 +0,0 @@
|
|
1
|
-
import "koi/elements/toolbar";
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<%# locals: (form:, figure:) %>
|
2
|
-
|
3
|
-
<%= form.govuk_image_field(:image, label: { size: "s" }) do %>
|
4
|
-
<%= form.govuk_text_field(:heading, label: { text: "Alternate text" }) %>
|
5
|
-
<%= form.govuk_text_field(:caption, label: { text: "Caption (optional)" }, optional: true) %>
|
6
|
-
<% end %>
|
7
|
-
|
8
|
-
<%= form.content_theme_field %>
|
9
|
-
<%= form.content_visible_field %>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<%# locals: (form:, table:) %>
|
2
|
-
|
3
|
-
<div class="flow" data-controller="content--editor--table">
|
4
|
-
<%= form.content_heading_fieldset %>
|
5
|
-
|
6
|
-
<% content = sanitize_content_table(normalize_content_table(form.object, heading: false)) %>
|
7
|
-
<%= form.govuk_text_area(:content, value: content, data: { content__editor__table_target: "input" }) %>
|
8
|
-
|
9
|
-
<%# hidden button to receive <Enter> events (HTML-default is to click first button in form) %>
|
10
|
-
<%= form.button("Save", hidden: "") %>
|
11
|
-
|
12
|
-
<%# hidden button to submit the table for re-rendering %>
|
13
|
-
<%= form.button("Update",
|
14
|
-
hidden: "",
|
15
|
-
formaction: table.persisted? ? katalyst_content.table_path : katalyst_content.tables_path,
|
16
|
-
data: { content__editor__table_target: "update" }) %>
|
17
|
-
|
18
|
-
<%= form.govuk_number_field(:heading_rows,
|
19
|
-
label: { text: "Heading rows" },
|
20
|
-
width: 2,
|
21
|
-
placeholder: 0,
|
22
|
-
min: 0,
|
23
|
-
data: { content__editor__table_target: "headerRows",
|
24
|
-
action: "input->content--editor--table#update" }) %>
|
25
|
-
|
26
|
-
<%= form.govuk_number_field(:heading_columns,
|
27
|
-
label: { text: "Heading columns" },
|
28
|
-
width: 2,
|
29
|
-
placeholder: 0,
|
30
|
-
min: 0,
|
31
|
-
data: { content__editor__table_target: "headerColumns",
|
32
|
-
action: "input->content--editor--table#update" }) %>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<%= form.content_theme_field %>
|
36
|
-
<%= form.content_visible_field %>
|