headmin 0.2.4 → 0.2.8
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/Gemfile.lock +2 -2
- data/app/helpers/headmin/admin_helper.rb +3 -59
- data/app/helpers/headmin/bootstrap_helper.rb +9 -0
- data/app/helpers/headmin/filter_helper.rb +7 -3
- data/app/helpers/headmin/form_helper.rb +36 -0
- data/app/helpers/headmin/request_helper.rb +39 -0
- data/app/models/concerns/headmin/fieldable.rb +3 -1
- data/app/services/block_service.rb +8 -4
- data/app/views/examples/admin.html.erb +1 -1
- data/app/views/headmin/_blocks.html.erb +1 -1
- data/app/views/headmin/_card.html.erb +3 -1
- data/app/views/headmin/_filters.html.erb +3 -3
- data/app/views/headmin/_pagination.html.erb +2 -1
- data/app/views/headmin/_table.html.erb +9 -3
- data/app/views/headmin/dropdown/_devise.html.erb +20 -10
- data/app/views/headmin/dropdown/_list.html.erb +17 -7
- data/app/views/headmin/filters/_date.html.erb +5 -3
- data/app/views/headmin/filters/_flatpickr.html.erb +57 -0
- data/app/views/headmin/forms/_base.html.erb +12 -11
- data/app/views/headmin/forms/_blocks.html.erb +11 -4
- data/app/views/headmin/forms/_date.html.erb +24 -12
- data/app/views/headmin/forms/_date_range.html.erb +84 -0
- data/app/views/headmin/forms/_flatpickr.html.erb +55 -0
- data/app/views/headmin/forms/_flatpickr_range.html.erb +61 -0
- data/app/views/headmin/forms/_hidden.html.erb +23 -0
- data/app/views/headmin/forms/_label.html.erb +4 -2
- data/app/views/headmin/forms/_repeater.html.erb +5 -8
- data/app/views/headmin/forms/_select.html.erb +14 -11
- data/app/views/headmin/forms/_text.html.erb +7 -9
- data/app/views/headmin/layout/_main.html.erb +11 -5
- data/app/views/headmin/table/_actions.html.erb +35 -11
- data/app/views/headmin/table/body/_row.html.erb +14 -6
- data/app/views/headmin/views/devise/confirmations/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +4 -4
- data/app/views/headmin/views/devise/registrations/_new.html.erb +3 -3
- data/app/views/headmin/views/devise/shared/_links.html.erb +7 -7
- data/app/views/headmin/views/devise/unlocks/_new.html.erb +1 -1
- data/config/locales/activerecord/en.yml +9 -0
- data/config/locales/activerecord/nl.yml +9 -0
- data/config/locales/headmin/table/en.yml +5 -1
- data/config/locales/headmin/table/nl.yml +5 -1
- data/config/locales/headmin/views/en.yml +1 -1
- data/config/locales/headmin/views/nl.yml +14 -14
- data/dist/css/headmin.css +57 -13
- data/dist/js/headmin.js +81 -514
- data/docs/blocks.md +0 -7
- data/lib/generators/headmin/blocks_generator.rb +4 -1
- data/lib/generators/headmin/devise_generator.rb +6 -2
- data/lib/generators/headmin/fields_generator.rb +4 -1
- data/lib/generators/templates/controllers/auth/confirmations_controller.rb +31 -0
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +31 -0
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +35 -0
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +63 -0
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +28 -0
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +31 -0
- data/lib/headmin/version.rb +1 -1
- data/package.json +3 -2
- data/src/js/headmin/controllers/blocks_controller.js +1 -1
- data/src/js/headmin/controllers/date_range_controller.js +34 -0
- data/src/js/headmin/controllers/filter_controller.js +1 -1
- data/src/js/headmin/controllers/filters_controller.js +1 -1
- data/src/js/headmin/controllers/flatpickr_controller.js +38 -0
- data/src/js/headmin/controllers/popup_controller.js +1 -1
- data/src/js/headmin/controllers/repeater_controller.js +8 -9
- data/src/js/headmin/controllers/table_actions_controller.js +74 -9
- data/src/js/headmin/controllers/table_controller.js +49 -58
- data/src/js/headmin/headmin.js +38 -21
- data/src/scss/headmin/form.scss +4 -0
- data/src/scss/headmin/table.scss +1 -0
- data/yarn.lock +940 -1058
- metadata +20 -2
data/docs/blocks.md
CHANGED
@@ -30,13 +30,6 @@ A hidden template form will be rendered for all types defined in `allow:`
|
|
30
30
|
```
|
31
31
|
|
32
32
|
For each type of block you want to include, create a template in `views/admin/blocks`.
|
33
|
-
Make sure to include a hidden field to store the name of the block.
|
34
|
-
|
35
|
-
```erb
|
36
|
-
# app/views/admin/blocks/_contact.html.erb
|
37
|
-
<%= form.hidden_field :name, value: :contact %>
|
38
|
-
...
|
39
|
-
```
|
40
33
|
|
41
34
|
### Usage in frontend
|
42
35
|
|
@@ -4,8 +4,11 @@ module Headmin
|
|
4
4
|
|
5
5
|
source_root File.expand_path('../../templates', __FILE__)
|
6
6
|
|
7
|
-
def
|
7
|
+
def copy_models
|
8
8
|
template 'models/block.rb', 'app/models/block.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
def copy_migrations
|
9
12
|
migration_template 'migrations/create_blocks.rb', 'db/migrate/create_blocks.rb'
|
10
13
|
end
|
11
14
|
|
@@ -4,9 +4,13 @@ module Headmin
|
|
4
4
|
|
5
5
|
source_root File.expand_path('../../templates', __FILE__)
|
6
6
|
|
7
|
-
def
|
7
|
+
def copy_controllers
|
8
|
+
directory 'controllers/auth', 'app/controllers/auth'
|
9
|
+
end
|
10
|
+
|
11
|
+
def copy_views
|
8
12
|
directory 'views/auth', 'app/views/auth'
|
9
|
-
copy_file 'views/layouts/auth.html.erb', 'app/layouts/auth.html.erb'
|
13
|
+
copy_file 'views/layouts/auth.html.erb', 'app/views/layouts/auth.html.erb'
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -4,8 +4,11 @@ module Headmin
|
|
4
4
|
|
5
5
|
source_root File.expand_path('../../templates', __FILE__)
|
6
6
|
|
7
|
-
def
|
7
|
+
def copy_models
|
8
8
|
template 'models/field.rb', 'app/models/field.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
def copy_migrations
|
9
12
|
migration_template 'migrations/create_fields.rb', 'db/migrate/create_fields.rb'
|
10
13
|
migration_template 'migrations/create_field_hierarchies.rb', 'db/migrate/create_field_hierarchies.rb'
|
11
14
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::ConfirmationsController < Devise::ConfirmationsController
|
4
|
+
layout 'auth'
|
5
|
+
# GET /resource/confirmation/new
|
6
|
+
# def new
|
7
|
+
# super
|
8
|
+
# end
|
9
|
+
|
10
|
+
# POST /resource/confirmation
|
11
|
+
# def create
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
|
15
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
16
|
+
# def show
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
|
20
|
+
# protected
|
21
|
+
|
22
|
+
# The path used after resending confirmation instructions.
|
23
|
+
# def after_resending_confirmation_instructions_path_for(resource_name)
|
24
|
+
# super(resource_name)
|
25
|
+
# end
|
26
|
+
|
27
|
+
# The path used after confirmation.
|
28
|
+
# def after_confirmation_path_for(resource_name, resource)
|
29
|
+
# super(resource_name, resource)
|
30
|
+
# end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
4
|
+
layout 'auth'
|
5
|
+
# You should configure your model like this:
|
6
|
+
# devise :omniauthable, omniauth_providers: [:twitter]
|
7
|
+
|
8
|
+
# You should also create an action method in this controller like this:
|
9
|
+
# def twitter
|
10
|
+
# end
|
11
|
+
|
12
|
+
# More info at:
|
13
|
+
# https://github.com/heartcombo/devise#omniauth
|
14
|
+
|
15
|
+
# GET|POST /resource/auth/twitter
|
16
|
+
# def passthru
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
|
20
|
+
# GET|POST /users/auth/twitter/callback
|
21
|
+
# def failure
|
22
|
+
# super
|
23
|
+
# end
|
24
|
+
|
25
|
+
# protected
|
26
|
+
|
27
|
+
# The path used when OmniAuth fails
|
28
|
+
# def after_omniauth_failure_path_for(scope)
|
29
|
+
# super(scope)
|
30
|
+
# end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::PasswordsController < Devise::PasswordsController
|
4
|
+
layout 'auth'
|
5
|
+
# GET /resource/password/new
|
6
|
+
# def new
|
7
|
+
# super
|
8
|
+
# end
|
9
|
+
|
10
|
+
# POST /resource/password
|
11
|
+
# def create
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
|
15
|
+
# GET /resource/password/edit?reset_password_token=abcdef
|
16
|
+
# def edit
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
|
20
|
+
# PUT /resource/password
|
21
|
+
# def update
|
22
|
+
# super
|
23
|
+
# end
|
24
|
+
|
25
|
+
# protected
|
26
|
+
|
27
|
+
# def after_resetting_password_path_for(resource)
|
28
|
+
# super(resource)
|
29
|
+
# end
|
30
|
+
|
31
|
+
# The path used after sending reset password instructions
|
32
|
+
# def after_sending_reset_password_instructions_path_for(resource_name)
|
33
|
+
# super(resource_name)
|
34
|
+
# end
|
35
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::RegistrationsController < Devise::RegistrationsController
|
4
|
+
layout 'auth'
|
5
|
+
# before_action :configure_sign_up_params, only: [:create]
|
6
|
+
# before_action :configure_account_update_params, only: [:update]
|
7
|
+
|
8
|
+
# GET /resource/sign_up
|
9
|
+
# def new
|
10
|
+
# super
|
11
|
+
# end
|
12
|
+
|
13
|
+
# POST /resource
|
14
|
+
# def create
|
15
|
+
# super
|
16
|
+
# end
|
17
|
+
|
18
|
+
# GET /resource/edit
|
19
|
+
# def edit
|
20
|
+
# super
|
21
|
+
# end
|
22
|
+
|
23
|
+
# PUT /resource
|
24
|
+
# def update
|
25
|
+
# super
|
26
|
+
# end
|
27
|
+
|
28
|
+
# DELETE /resource
|
29
|
+
# def destroy
|
30
|
+
# super
|
31
|
+
# end
|
32
|
+
|
33
|
+
# GET /resource/cancel
|
34
|
+
# Forces the session data which is usually expired after sign
|
35
|
+
# in to be expired now. This is useful if the user wants to
|
36
|
+
# cancel oauth signing in/up in the middle of the process,
|
37
|
+
# removing all OAuth session data.
|
38
|
+
# def cancel
|
39
|
+
# super
|
40
|
+
# end
|
41
|
+
|
42
|
+
# protected
|
43
|
+
|
44
|
+
# If you have extra params to permit, append them to the sanitizer.
|
45
|
+
# def configure_sign_up_params
|
46
|
+
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
|
47
|
+
# end
|
48
|
+
|
49
|
+
# If you have extra params to permit, append them to the sanitizer.
|
50
|
+
# def configure_account_update_params
|
51
|
+
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
|
52
|
+
# end
|
53
|
+
|
54
|
+
# The path used after sign up.
|
55
|
+
# def after_sign_up_path_for(resource)
|
56
|
+
# super(resource)
|
57
|
+
# end
|
58
|
+
|
59
|
+
# The path used after sign up for inactive accounts.
|
60
|
+
# def after_inactive_sign_up_path_for(resource)
|
61
|
+
# super(resource)
|
62
|
+
# end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::SessionsController < Devise::SessionsController
|
4
|
+
layout 'auth'
|
5
|
+
# before_action :configure_sign_in_params, only: [:create]
|
6
|
+
|
7
|
+
# GET /resource/sign_in
|
8
|
+
# def new
|
9
|
+
# super
|
10
|
+
# end
|
11
|
+
|
12
|
+
# POST /resource/sign_in
|
13
|
+
# def create
|
14
|
+
# super
|
15
|
+
# end
|
16
|
+
|
17
|
+
# DELETE /resource/sign_out
|
18
|
+
# def destroy
|
19
|
+
# super
|
20
|
+
# end
|
21
|
+
|
22
|
+
# protected
|
23
|
+
|
24
|
+
# If you have extra params to permit, append them to the sanitizer.
|
25
|
+
# def configure_sign_in_params
|
26
|
+
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
|
27
|
+
# end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Auth::UnlocksController < Devise::UnlocksController
|
4
|
+
layout 'auth'
|
5
|
+
# GET /resource/unlock/new
|
6
|
+
# def new
|
7
|
+
# super
|
8
|
+
# end
|
9
|
+
|
10
|
+
# POST /resource/unlock
|
11
|
+
# def create
|
12
|
+
# super
|
13
|
+
# end
|
14
|
+
|
15
|
+
# GET /resource/unlock?unlock_token=abcdef
|
16
|
+
# def show
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
|
20
|
+
# protected
|
21
|
+
|
22
|
+
# The path used after sending unlock password instructions
|
23
|
+
# def after_sending_unlock_instructions_path_for(resource)
|
24
|
+
# super(resource)
|
25
|
+
# end
|
26
|
+
|
27
|
+
# The path used after unlocking the resource
|
28
|
+
# def after_unlock_path_for(resource)
|
29
|
+
# super(resource)
|
30
|
+
# end
|
31
|
+
end
|
data/lib/headmin/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "headmin",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.6",
|
4
4
|
"description": "Admin component library",
|
5
5
|
"main": "src/js/headmin.js",
|
6
6
|
"sass": "src/scss/headmin.scss",
|
@@ -20,13 +20,14 @@
|
|
20
20
|
},
|
21
21
|
"homepage": "https://github.com/insiting/headmin#readme",
|
22
22
|
"dependencies": {
|
23
|
+
"@hotwired/stimulus": "^3.0",
|
24
|
+
"@hotwired/stimulus-webpack-helpers": "^1.0",
|
23
25
|
"@popperjs/core": "^2.9.3",
|
24
26
|
"@rails/ujs": "^6.0.0",
|
25
27
|
"bootstrap": "^5.1.1",
|
26
28
|
"ckeditor5-build-classic-simple-upload-adapter-image-resize": "^1.0.4",
|
27
29
|
"flatpickr": "^4.6.9",
|
28
30
|
"sortablejs": "^1.13.0",
|
29
|
-
"stimulus": "^2.0.0",
|
30
31
|
"tom-select": "^2.0.0-rc.4"
|
31
32
|
},
|
32
33
|
"devDependencies": {
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
|
+
import Sortable from "sortablejs";
|
3
|
+
import { createPopper } from '@popperjs/core';
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static get targets() {
|
7
|
+
return ["dateInput", "startDateInput", "endDateInput"]
|
8
|
+
}
|
9
|
+
|
10
|
+
update(event) {
|
11
|
+
const flatpickr = event.target._flatpickr
|
12
|
+
const startDate = flatpickr.selectedDates[0]
|
13
|
+
const endDate = flatpickr.selectedDates[1]
|
14
|
+
|
15
|
+
this.setStartDateInputValue(this.formatDate(startDate))
|
16
|
+
this.setEndDateInputValue(this.formatDate(endDate))
|
17
|
+
}
|
18
|
+
|
19
|
+
setStartDateInputValue(value) {
|
20
|
+
this.startDateInputTarget.value = value
|
21
|
+
}
|
22
|
+
|
23
|
+
setEndDateInputValue(value) {
|
24
|
+
this.endDateInputTarget.value = value
|
25
|
+
}
|
26
|
+
|
27
|
+
formatDate(date) {
|
28
|
+
if(date instanceof Date) {
|
29
|
+
return date.toLocaleDateString('nl-BE', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
30
|
+
} else {
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
|
+
import flatpickr from "flatpickr";
|
3
|
+
import {Dutch} from "flatpickr/dist/l10n/nl.js"
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static get targets() {
|
7
|
+
return ["input"]
|
8
|
+
}
|
9
|
+
|
10
|
+
connect() {
|
11
|
+
const options = {...this.defaultOptions(), ...this.options()}
|
12
|
+
flatpickr(this.inputTarget, options);
|
13
|
+
}
|
14
|
+
|
15
|
+
options() {
|
16
|
+
return JSON.parse(this.inputTarget.getAttribute('data-flatpickr-options'))
|
17
|
+
}
|
18
|
+
|
19
|
+
defaultOptions() {
|
20
|
+
return {
|
21
|
+
allowInput: true,
|
22
|
+
dateFormat: 'd/m/Y',
|
23
|
+
locale: this.getLocale(I18n.locale)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
getLocale(locale) {
|
28
|
+
const locales = this.locales()
|
29
|
+
return locales[locale]
|
30
|
+
}
|
31
|
+
|
32
|
+
locales() {
|
33
|
+
return {
|
34
|
+
en: null,
|
35
|
+
nl: Dutch
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {Controller} from "stimulus"
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
2
|
import Sortable from "sortablejs";
|
3
3
|
|
4
4
|
export default class extends Controller {
|
@@ -52,8 +52,8 @@ export default class extends Controller {
|
|
52
52
|
let rowIndex = button.dataset.rowIndex
|
53
53
|
|
54
54
|
// Prepare html from template
|
55
|
-
|
56
|
-
html = this.replaceIdsWithTimestamps(
|
55
|
+
const template = this.getTemplate(templateName)
|
56
|
+
const html = this.replaceIdsWithTimestamps(template)
|
57
57
|
|
58
58
|
// Fallback to last row if no index is set
|
59
59
|
if (rowIndex) {
|
@@ -92,16 +92,15 @@ export default class extends Controller {
|
|
92
92
|
this.toggleEmpty()
|
93
93
|
}
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
getTemplate(name) {
|
96
|
+
return this.templateTargets.filter((template) => {
|
97
97
|
return template.dataset.templateName === name
|
98
98
|
})[0]
|
99
|
-
return template.innerHTML
|
100
99
|
}
|
101
100
|
|
102
|
-
replaceIdsWithTimestamps(
|
103
|
-
const regex = new RegExp(
|
104
|
-
return
|
101
|
+
replaceIdsWithTimestamps(template) {
|
102
|
+
const regex = new RegExp(template.dataset.templateIdRegex, "g")
|
103
|
+
return template.innerHTML.replace(regex, new Date().getTime())
|
105
104
|
}
|
106
105
|
|
107
106
|
visibleRowsCount() {
|
@@ -1,33 +1,98 @@
|
|
1
|
-
import {Controller} from "stimulus"
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
4
|
static get targets() {
|
5
|
-
return ["form", "select", "method", "button"]
|
5
|
+
return ["wrapper", "form", "select", "method", "button", "idInputTemplate", "id", "counter"]
|
6
6
|
}
|
7
7
|
|
8
8
|
connect() {
|
9
|
-
this.
|
9
|
+
this.wrapperTarget.addEventListener('idSelectionChanged', (event) => {
|
10
|
+
this.updateIdFields(event.detail.ids)
|
11
|
+
this.updateCounter(event.detail.count)
|
12
|
+
this.toggleCounter(event.detail.count)
|
13
|
+
})
|
14
|
+
|
10
15
|
}
|
11
16
|
|
12
17
|
update(event) {
|
13
18
|
event.preventDefault()
|
14
|
-
|
19
|
+
this.updateFormAction()
|
20
|
+
this.updateFormMethod()
|
21
|
+
this.updateButton()
|
22
|
+
}
|
23
|
+
|
24
|
+
updateIdFields(ids) {
|
25
|
+
this.removeIds()
|
26
|
+
if (ids instanceof Array) {
|
27
|
+
ids.forEach((id) => {
|
28
|
+
this.addId(id)
|
29
|
+
})
|
30
|
+
} else {
|
31
|
+
this.addId('')
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
updateCounter(count) {
|
36
|
+
let htmlString = ''
|
37
|
+
switch (count) {
|
38
|
+
case 0:
|
39
|
+
htmlString = this.counterTarget.getAttribute('data-items-zero')
|
40
|
+
break;
|
41
|
+
case 1:
|
42
|
+
htmlString = this.counterTarget.getAttribute('data-items-one')
|
43
|
+
break;
|
44
|
+
default:
|
45
|
+
htmlString = this.counterTarget.getAttribute('data-items-other')
|
46
|
+
htmlString = htmlString.replace(/<b>[\s\S]*?<\/b>/, `<b>${count}<\/b>`);
|
47
|
+
}
|
48
|
+
this.counterTarget.innerHTML = htmlString;
|
49
|
+
}
|
50
|
+
|
51
|
+
toggleCounter(count) {
|
52
|
+
if (count > 0) {
|
53
|
+
this.wrapperTarget.classList.remove('d-none')
|
54
|
+
} else {
|
55
|
+
this.wrapperTarget.classList.add('d-none')
|
56
|
+
}
|
57
|
+
}
|
15
58
|
|
16
|
-
|
59
|
+
updateFormAction() {
|
17
60
|
this.formTarget.action = this.selectTarget.value
|
61
|
+
}
|
18
62
|
|
19
|
-
|
63
|
+
updateFormMethod() {
|
64
|
+
const option = this.selectedOption()
|
20
65
|
this.methodTarget.value = option.dataset.method
|
66
|
+
}
|
21
67
|
|
22
|
-
|
68
|
+
updateButton() {
|
69
|
+
const option = this.selectedOption()
|
23
70
|
const confirm = option.dataset.confirm
|
24
|
-
if(confirm) {
|
71
|
+
if (confirm) {
|
25
72
|
this.buttonTarget.dataset.confirm = confirm
|
26
73
|
} else {
|
27
74
|
this.buttonTarget.removeAttribute('data-confirm')
|
28
75
|
}
|
76
|
+
this.enableButton()
|
77
|
+
}
|
29
78
|
|
30
|
-
|
79
|
+
selectedOption() {
|
80
|
+
return this.selectTarget.options[this.selectTarget.selectedIndex]
|
81
|
+
}
|
82
|
+
|
83
|
+
enableButton() {
|
31
84
|
this.buttonTarget.removeAttribute('disabled')
|
32
85
|
}
|
86
|
+
|
87
|
+
addId(id) {
|
88
|
+
const template = this.idInputTemplateTarget
|
89
|
+
const input = template.innerHTML.replace(/ID/g, id)
|
90
|
+
this.formTarget.insertAdjacentHTML('afterbegin', input)
|
91
|
+
}
|
92
|
+
|
93
|
+
removeIds() {
|
94
|
+
this.idTargets.forEach((input) => {
|
95
|
+
this.formTarget.removeChild(input)
|
96
|
+
});
|
97
|
+
}
|
33
98
|
}
|