headmin 0.4.2 → 0.5.2
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/CHANGELOG.md +10 -3
- data/Gemfile +14 -0
- data/Gemfile.lock +78 -1
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +12 -6
- data/app/assets/javascripts/headmin/controllers/filter_controller.js +61 -11
- data/app/assets/javascripts/headmin/controllers/filter_row_controller.js +50 -0
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +2 -6
- data/app/assets/javascripts/headmin/controllers/media_controller.js +237 -0
- data/app/assets/javascripts/headmin/controllers/media_modal_controller.js +110 -0
- data/app/assets/javascripts/headmin/controllers/popup_controller.js +3 -1
- data/app/assets/javascripts/headmin/controllers/remote_modal_controller.js +10 -0
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +16 -21
- data/app/assets/javascripts/headmin/controllers/textarea_controller.js +34 -0
- data/app/assets/javascripts/headmin/index.js +10 -0
- data/app/assets/javascripts/headmin.js +413 -38
- data/app/assets/stylesheets/headmin/filter.scss +74 -0
- data/app/assets/stylesheets/headmin/forms/file.scss +40 -5
- data/app/assets/stylesheets/headmin/forms/media.scss +10 -0
- data/app/assets/stylesheets/headmin/forms/repeater.scss +4 -0
- data/app/assets/stylesheets/headmin/forms.scss +7 -0
- data/app/assets/stylesheets/headmin/general.scss +0 -1
- data/app/assets/stylesheets/headmin/layout/body.scss +5 -0
- data/app/assets/stylesheets/headmin/layout/sidebar.scss +0 -1
- data/app/assets/stylesheets/headmin/media/index.scss +9 -0
- data/app/assets/stylesheets/headmin/media.scss +1 -0
- data/app/assets/stylesheets/headmin/popup.scss +0 -1
- data/app/assets/stylesheets/headmin/table.scss +15 -0
- data/app/assets/stylesheets/headmin.css +137 -9
- data/app/assets/stylesheets/headmin.scss +1 -0
- data/app/controllers/concerns/headmin/filterable.rb +27 -0
- data/app/controllers/headmin/media_controller.rb +52 -0
- data/app/controllers/headmin_controller.rb +2 -0
- data/app/models/concerns/headmin/field.rb +0 -1
- data/app/models/concerns/headmin/fieldable.rb +10 -1
- data/app/models/concerns/headmin/form/hintable.rb +6 -1
- data/app/models/headmin/blocks_view.rb +1 -1
- data/app/models/headmin/filter/base.rb +238 -0
- data/app/models/headmin/filter/base_view.rb +64 -0
- data/app/models/headmin/filter/boolean.rb +15 -0
- data/app/models/headmin/filter/boolean_view.rb +61 -0
- data/app/models/headmin/filter/button_view.rb +25 -0
- data/app/models/headmin/filter/conditional_view.rb +16 -0
- data/app/models/headmin/filter/date.rb +67 -0
- data/app/models/headmin/filter/date_view.rb +52 -0
- data/app/models/headmin/filter/flatpickr_view.rb +54 -0
- data/app/models/headmin/filter/menu_item_view.rb +6 -0
- data/app/models/headmin/filter/money.rb +13 -0
- data/app/models/headmin/filter/number.rb +27 -0
- data/app/models/headmin/filter/number_view.rb +54 -0
- data/app/models/headmin/filter/operator_view.rb +30 -0
- data/app/models/headmin/filter/options_view.rb +61 -0
- data/app/models/headmin/filter/row_view.rb +13 -0
- data/app/models/headmin/filter/search.rb +18 -0
- data/app/models/headmin/filter/search_view.rb +31 -0
- data/app/models/headmin/filter/text.rb +25 -0
- data/app/models/headmin/filter/text_view.rb +53 -0
- data/app/models/headmin/filters.rb +29 -0
- data/app/models/headmin/form/color_view.rb +48 -0
- data/app/models/headmin/form/datetime_range_view.rb +25 -0
- data/app/models/headmin/form/datetime_view.rb +45 -0
- data/app/models/headmin/form/flatpickr_range_view.rb +4 -15
- data/app/models/headmin/form/flatpickr_view.rb +3 -12
- data/app/models/headmin/form/media_view.rb +113 -0
- data/app/models/headmin/form/textarea_view.rb +6 -1
- data/app/models/view_model.rb +1 -1
- data/app/views/headmin/_blocks.html.erb +3 -3
- data/app/views/headmin/_breadcrumbs.html.erb +1 -1
- data/app/views/headmin/_dropdown.html.erb +1 -1
- data/app/views/headmin/_filters.html.erb +9 -9
- data/app/views/headmin/_heading.html.erb +1 -1
- data/app/views/headmin/_notifications.html.erb +1 -1
- data/app/views/headmin/_pagination.html.erb +2 -2
- data/app/views/headmin/dropdown/_devise.html.erb +7 -7
- data/app/views/headmin/dropdown/_list.html.erb +1 -1
- data/app/views/headmin/filters/_base.html.erb +95 -0
- data/app/views/headmin/filters/_boolean.html.erb +23 -0
- data/app/views/headmin/filters/_date.html.erb +14 -38
- data/app/views/headmin/filters/_flatpickr.html.erb +15 -48
- data/app/views/headmin/filters/_number.html.erb +23 -0
- data/app/views/headmin/filters/_options.html.erb +24 -0
- data/app/views/headmin/filters/_search.html.erb +14 -12
- data/app/views/headmin/filters/_text.html.erb +23 -0
- data/app/views/headmin/filters/filter/_button.html.erb +9 -10
- data/app/views/headmin/filters/filter/_conditional.html.erb +18 -0
- data/app/views/headmin/filters/filter/_menu_item.html.erb +5 -2
- data/app/views/headmin/filters/filter/_null_select.html.erb +8 -0
- data/app/views/headmin/filters/filter/_operator.html.erb +16 -0
- data/app/views/headmin/filters/filter/_row.html.erb +11 -0
- data/app/views/headmin/forms/_autocomplete.html.erb +2 -2
- data/app/views/headmin/forms/_blocks.html.erb +3 -3
- data/app/views/headmin/forms/_checkbox.html.erb +5 -5
- data/app/views/headmin/forms/_color.html.erb +32 -0
- data/app/views/headmin/forms/_date.html.erb +8 -8
- data/app/views/headmin/forms/_datetime.html.erb +41 -0
- data/app/views/headmin/forms/_datetime_range.html.erb +40 -0
- data/app/views/headmin/forms/_email.html.erb +9 -9
- data/app/views/headmin/forms/_file.html.erb +9 -9
- data/app/views/headmin/forms/_flatpickr.html.erb +1 -1
- data/app/views/headmin/forms/_flatpickr_range.html.erb +9 -10
- data/app/views/headmin/forms/_hidden.html.erb +1 -1
- data/app/views/headmin/forms/_hint.html.erb +7 -2
- data/app/views/headmin/forms/_media.html.erb +58 -0
- data/app/views/headmin/forms/_number.html.erb +8 -8
- data/app/views/headmin/forms/_password.html.erb +7 -7
- data/app/views/headmin/forms/_redactorx.html.erb +2 -2
- data/app/views/headmin/forms/_search.html.erb +9 -9
- data/app/views/headmin/forms/_select.html.erb +8 -8
- data/app/views/headmin/forms/_switch.html.erb +2 -2
- data/app/views/headmin/forms/_text.html.erb +9 -9
- data/app/views/headmin/forms/_textarea.html.erb +7 -7
- data/app/views/headmin/forms/_url.html.erb +9 -9
- data/app/views/headmin/forms/_validation.html.erb +1 -1
- data/app/views/headmin/forms/_wysiwyg.html.erb +2 -2
- data/app/views/headmin/forms/fields/_base.html.erb +1 -1
- data/app/views/headmin/forms/fields/_file.html.erb +1 -1
- data/app/views/headmin/forms/fields/_files.html.erb +1 -1
- data/app/views/headmin/forms/fields/_group.html.erb +2 -2
- data/app/views/headmin/forms/fields/_list.html.erb +1 -1
- data/app/views/headmin/forms/fields/_text.html.erb +1 -1
- data/app/views/headmin/forms/media/_item.html.erb +32 -0
- data/app/views/headmin/forms/media/_validation.html.erb +10 -0
- data/app/views/headmin/forms/repeater/_row.html.erb +12 -11
- data/app/views/headmin/layout/_footer.html.erb +1 -1
- data/app/views/headmin/layout/_main.html.erb +2 -0
- data/app/views/headmin/layout/_remote_modal.html.erb +1 -0
- data/app/views/headmin/layout/_sidebar.html.erb +1 -1
- data/app/views/headmin/media/_item.html.erb +17 -0
- data/app/views/headmin/media/_media_item_modal.html.erb +51 -0
- data/app/views/headmin/media/_modal.html.erb +35 -0
- data/app/views/headmin/media/create.turbo_stream.erb +5 -0
- data/app/views/headmin/media/index.html.erb +3 -0
- data/app/views/headmin/media/show.html.erb +9 -0
- data/app/views/headmin/media/update.turbo_stream.erb +3 -0
- data/app/views/headmin/nav/item/_devise.html.erb +7 -7
- data/app/views/headmin/table/_actions.html.erb +1 -4
- data/app/views/headmin/table/actions/_action.html.erb +3 -3
- data/app/views/headmin/table/actions/_delete.html.erb +2 -2
- data/app/views/headmin/table/actions/_export.html.erb +1 -1
- data/app/views/headmin/table/body/_color.html.erb +10 -0
- data/app/views/headmin/table/body/_image.html.erb +18 -0
- data/app/views/headmin/table/foot/_cell.html.erb +1 -1
- data/app/views/headmin/table/foot/_id.html.erb +1 -1
- data/app/views/headmin/views/devise/confirmations/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_new.html.erb +2 -2
- data/app/views/headmin/views/devise/sessions/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/unlocks/_new.html.erb +2 -2
- data/config/locales/devise/nl.yml +1 -1
- data/config/locales/en.yml +4 -0
- data/config/locales/headmin/dropdown/en.yml +6 -0
- data/config/locales/headmin/dropdown/nl.yml +6 -0
- data/config/locales/headmin/filters/en.yml +26 -1
- data/config/locales/headmin/filters/nl.yml +26 -1
- data/config/locales/headmin/forms/en.yml +8 -0
- data/config/locales/headmin/forms/nl.yml +8 -0
- data/config/locales/headmin/layout/en.yml +0 -9
- data/config/locales/headmin/layout/nl.yml +0 -9
- data/config/locales/headmin/media/en.yml +23 -0
- data/config/locales/headmin/media/nl.yml +22 -0
- data/config/locales/headmin/nav/en.yml +7 -0
- data/config/locales/headmin/nav/nl.yml +7 -0
- data/config/locales/headmin/table/en.yml +2 -0
- data/config/locales/headmin/table/nl.yml +2 -0
- data/config/locales/nl.yml +4 -0
- data/config/routes.rb +10 -0
- data/lib/generators/templates/views/auth/confirmations/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/confirmation_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/email_changed.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/password_change.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/reset_password_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/mailer/unlock_instructions.html.erb +1 -1
- data/lib/generators/templates/views/auth/passwords/edit.html.erb +1 -1
- data/lib/generators/templates/views/auth/passwords/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/registrations/edit.html.erb +1 -1
- data/lib/generators/templates/views/auth/registrations/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/sessions/new.html.erb +1 -1
- data/lib/generators/templates/views/auth/unlocks/new.html.erb +1 -1
- data/lib/headmin/version.rb +1 -1
- data/package.json +1 -1
- metadata +70 -7
- data/.lock-487e157d270f3062a98b7b2a012753708-1272821827 +0 -0
- data/app/controllers/concerns/headmin/filter.rb +0 -5
- data/app/controllers/concerns/headmin/searchable.rb +0 -15
- data/app/views/headmin/filters/_select.html.erb +0 -45
- data/app/views/headmin/filters/filter/_template.html.erb +0 -13
@@ -7457,9 +7457,6 @@ var blocks_controller_default = class extends Controller {
|
|
7457
7457
|
|
7458
7458
|
// app/assets/javascripts/headmin/controllers/date_range_controller.js
|
7459
7459
|
var date_range_controller_default = class extends Controller {
|
7460
|
-
static get targets() {
|
7461
|
-
return ["dateInput", "startDateInput", "endDateInput"];
|
7462
|
-
}
|
7463
7460
|
update(event) {
|
7464
7461
|
const flatpickr2 = event.target._flatpickr;
|
7465
7462
|
const startDate = flatpickr2.selectedDates[0];
|
@@ -7468,10 +7465,18 @@ var date_range_controller_default = class extends Controller {
|
|
7468
7465
|
this.setEndDateInputValue(this.formatDate(endDate));
|
7469
7466
|
}
|
7470
7467
|
setStartDateInputValue(value) {
|
7471
|
-
|
7468
|
+
const startDateInput = this.startDateInput();
|
7469
|
+
startDateInput.value = value;
|
7472
7470
|
}
|
7473
7471
|
setEndDateInputValue(value) {
|
7474
|
-
|
7472
|
+
const endDateInput = this.endDateInput();
|
7473
|
+
endDateInput.value = value;
|
7474
|
+
}
|
7475
|
+
startDateInput() {
|
7476
|
+
return this.element.nextElementSibling;
|
7477
|
+
}
|
7478
|
+
endDateInput() {
|
7479
|
+
return this.startDateInput().nextElementSibling;
|
7475
7480
|
}
|
7476
7481
|
formatDate(date) {
|
7477
7482
|
if (date instanceof Date) {
|
@@ -7704,18 +7709,16 @@ var file_preview_controller_default = class extends Controller {
|
|
7704
7709
|
// app/assets/javascripts/headmin/controllers/filter_controller.js
|
7705
7710
|
var filter_controller_default = class extends Controller {
|
7706
7711
|
static get targets() {
|
7707
|
-
return ["button", "popup"];
|
7712
|
+
return ["button", "popup", "conditional", "operator", "value", "hidden", "wrapper", "template", "row"];
|
7713
|
+
}
|
7714
|
+
static get values() {
|
7715
|
+
return {
|
7716
|
+
name: String
|
7717
|
+
};
|
7708
7718
|
}
|
7709
7719
|
connect() {
|
7710
7720
|
this.element.controller = this;
|
7711
|
-
|
7712
|
-
this.handleOutsideClick(event);
|
7713
|
-
});
|
7714
|
-
}
|
7715
|
-
handleOutsideClick(event) {
|
7716
|
-
if (!this.isClickedInside(event)) {
|
7717
|
-
this.close();
|
7718
|
-
}
|
7721
|
+
this.updateHiddenValue();
|
7719
7722
|
}
|
7720
7723
|
toggle(event) {
|
7721
7724
|
const expanded = this.buttonTarget.getAttribute("aria-expanded") === "true";
|
@@ -7733,6 +7736,29 @@ var filter_controller_default = class extends Controller {
|
|
7733
7736
|
this.buttonTarget.setAttribute("aria-expanded", "false");
|
7734
7737
|
this.popupTarget.classList.add("closed");
|
7735
7738
|
}
|
7739
|
+
add(event) {
|
7740
|
+
event.preventDefault();
|
7741
|
+
const html = this.getTemplateHTML();
|
7742
|
+
this.wrapperTarget.insertAdjacentHTML("beforeend", html);
|
7743
|
+
}
|
7744
|
+
remove(event) {
|
7745
|
+
event.preventDefault();
|
7746
|
+
const inputGroup = event.currentTarget.closest('[data-filter-target="row"]');
|
7747
|
+
const conditional = inputGroup.previousElementSibling != null ? inputGroup.previousElementSibling : inputGroup.nextElementSibling;
|
7748
|
+
inputGroup.remove();
|
7749
|
+
if (conditional != null)
|
7750
|
+
conditional.remove();
|
7751
|
+
this.updateHiddenValue();
|
7752
|
+
if (this.valueTargets.length === 0) {
|
7753
|
+
this.removeFilter();
|
7754
|
+
}
|
7755
|
+
}
|
7756
|
+
removeFilter() {
|
7757
|
+
const form = this.buttonTarget.closest("form");
|
7758
|
+
this.buttonTarget.remove();
|
7759
|
+
this.popupTarget.remove();
|
7760
|
+
form.submit();
|
7761
|
+
}
|
7736
7762
|
isClickedInside(event) {
|
7737
7763
|
if (!event) {
|
7738
7764
|
return false;
|
@@ -7742,6 +7768,65 @@ var filter_controller_default = class extends Controller {
|
|
7742
7768
|
const inAddButton = event.target.dataset.action === "click->filters#add";
|
7743
7769
|
return inPopup || inButton || inAddButton;
|
7744
7770
|
}
|
7771
|
+
updateHiddenValue() {
|
7772
|
+
this.hiddenTarget.value = this.buildInstructionString();
|
7773
|
+
}
|
7774
|
+
buildInstructionString() {
|
7775
|
+
let string = "";
|
7776
|
+
for (const row of this.rowTargets) {
|
7777
|
+
const conditional = row.previousElementSibling ? row.previousElementSibling.querySelector('[data-filter-target="conditional"]').value : null;
|
7778
|
+
const operator = row.querySelector('[data-filter-target="operator"]').value;
|
7779
|
+
const value = row.querySelector('[data-filter-target="value"]').value;
|
7780
|
+
string += `${conditional || ""}${operator}:${value}`;
|
7781
|
+
}
|
7782
|
+
return string;
|
7783
|
+
}
|
7784
|
+
getTemplateHTML() {
|
7785
|
+
const template = this.templateTarget;
|
7786
|
+
return template.innerHTML;
|
7787
|
+
}
|
7788
|
+
};
|
7789
|
+
|
7790
|
+
// app/assets/javascripts/headmin/controllers/filter_row_controller.js
|
7791
|
+
var filter_row_controller_default = class extends Controller {
|
7792
|
+
static get targets() {
|
7793
|
+
return ["original", "operator", "null"];
|
7794
|
+
}
|
7795
|
+
connect() {
|
7796
|
+
this.operatorTarget.addEventListener("change", () => this.handleOperatorChange());
|
7797
|
+
this.handleOperatorChange();
|
7798
|
+
}
|
7799
|
+
handleOperatorChange() {
|
7800
|
+
if (this.operatorTarget.value === "is_null" || this.operatorTarget.value === "is_not_null") {
|
7801
|
+
this.toggleNullInput();
|
7802
|
+
} else {
|
7803
|
+
this.toggleOriginalInput();
|
7804
|
+
}
|
7805
|
+
}
|
7806
|
+
toggleNullInput() {
|
7807
|
+
this.hideOriginal();
|
7808
|
+
this.showNull();
|
7809
|
+
}
|
7810
|
+
toggleOriginalInput() {
|
7811
|
+
this.showOriginal();
|
7812
|
+
this.hideNull();
|
7813
|
+
}
|
7814
|
+
hideOriginal() {
|
7815
|
+
this.originalTarget.style.display = "none";
|
7816
|
+
this.originalTarget.setAttribute("data-filter-target", "value_original");
|
7817
|
+
}
|
7818
|
+
showOriginal() {
|
7819
|
+
this.originalTarget.style.display = "block";
|
7820
|
+
this.originalTarget.setAttribute("data-filter-target", "value");
|
7821
|
+
}
|
7822
|
+
hideNull() {
|
7823
|
+
this.nullTarget.style.display = "none";
|
7824
|
+
this.nullTarget.setAttribute("data-filter-target", "value_null");
|
7825
|
+
}
|
7826
|
+
showNull() {
|
7827
|
+
this.nullTarget.style.display = "block";
|
7828
|
+
this.nullTarget.setAttribute("data-filter-target", "value");
|
7829
|
+
}
|
7745
7830
|
};
|
7746
7831
|
|
7747
7832
|
// app/assets/javascripts/headmin/controllers/filters_controller.js
|
@@ -9975,15 +10060,12 @@ var i18n_default = class {
|
|
9975
10060
|
|
9976
10061
|
// app/assets/javascripts/headmin/controllers/flatpickr_controller.js
|
9977
10062
|
var flatpickr_controller_default = class extends Controller {
|
9978
|
-
static get targets() {
|
9979
|
-
return ["input"];
|
9980
|
-
}
|
9981
10063
|
connect() {
|
9982
10064
|
const options = { ...this.defaultOptions(), ...this.options() };
|
9983
|
-
esm_default(this.
|
10065
|
+
esm_default(this.element, options);
|
9984
10066
|
}
|
9985
10067
|
options() {
|
9986
|
-
return JSON.parse(this.
|
10068
|
+
return JSON.parse(this.element.getAttribute("data-flatpickr"));
|
9987
10069
|
}
|
9988
10070
|
defaultOptions() {
|
9989
10071
|
return {
|
@@ -10011,6 +10093,260 @@ var hello_controller_default = class extends Controller {
|
|
10011
10093
|
}
|
10012
10094
|
};
|
10013
10095
|
|
10096
|
+
// app/assets/javascripts/headmin/controllers/media_controller.js
|
10097
|
+
var media_controller_default = class extends Controller {
|
10098
|
+
static get targets() {
|
10099
|
+
return ["item", "template", "thumbnails", "modalButton", "placeholder", "validationInput", "count", "editButton"];
|
10100
|
+
}
|
10101
|
+
connect() {
|
10102
|
+
document.addEventListener("mediaSelectionSubmitted", (event) => {
|
10103
|
+
if (event.detail.name === this.element.dataset.name) {
|
10104
|
+
this.selectItems(event.detail.items);
|
10105
|
+
}
|
10106
|
+
});
|
10107
|
+
if (this.hasSorting()) {
|
10108
|
+
this.initSortable();
|
10109
|
+
}
|
10110
|
+
this.validate();
|
10111
|
+
}
|
10112
|
+
destroy(event) {
|
10113
|
+
const item = event.currentTarget.closest("[data-media-target='item']");
|
10114
|
+
this.destroyItem(item);
|
10115
|
+
}
|
10116
|
+
syncIds() {
|
10117
|
+
const ids = this.activeIds();
|
10118
|
+
this.modalButtonTargets.forEach((button) => {
|
10119
|
+
const url = new URL(button.getAttribute("href"));
|
10120
|
+
url.searchParams.delete("ids[]");
|
10121
|
+
ids.forEach((id) => {
|
10122
|
+
url.searchParams.append("ids[]", id);
|
10123
|
+
});
|
10124
|
+
button.setAttribute("href", url.toString());
|
10125
|
+
});
|
10126
|
+
}
|
10127
|
+
initSortable() {
|
10128
|
+
sortable_esm_default.create(this.thumbnailsTarget, {
|
10129
|
+
handle: ".media-drag-sort-handle",
|
10130
|
+
onEnd: (event) => {
|
10131
|
+
this.resetPositions();
|
10132
|
+
}
|
10133
|
+
});
|
10134
|
+
}
|
10135
|
+
hasSorting() {
|
10136
|
+
return this.element.dataset.sort === "true";
|
10137
|
+
}
|
10138
|
+
destroyItem(item) {
|
10139
|
+
this.removeItem(item);
|
10140
|
+
this.postProcess();
|
10141
|
+
}
|
10142
|
+
selectItems(items) {
|
10143
|
+
this.removeAllItems();
|
10144
|
+
this.addItems(items);
|
10145
|
+
this.postProcess();
|
10146
|
+
}
|
10147
|
+
postProcess() {
|
10148
|
+
this.resetPositions();
|
10149
|
+
this.syncIds();
|
10150
|
+
this.togglePlaceholder();
|
10151
|
+
this.validate();
|
10152
|
+
}
|
10153
|
+
validate() {
|
10154
|
+
this.clearValidation();
|
10155
|
+
if (this.element.dataset.required === "0")
|
10156
|
+
return;
|
10157
|
+
this.validateMinimum();
|
10158
|
+
this.validateMaximum();
|
10159
|
+
}
|
10160
|
+
clearValidation() {
|
10161
|
+
this.validationInputTarget.setCustomValidity("");
|
10162
|
+
}
|
10163
|
+
validateMinimum() {
|
10164
|
+
const count = this.activeItems().length;
|
10165
|
+
if (count < this.minActiveItems()) {
|
10166
|
+
this.validationInputTarget.setCustomValidity(this.validationInputTarget.dataset.minMessage);
|
10167
|
+
}
|
10168
|
+
}
|
10169
|
+
validateMaximum() {
|
10170
|
+
const count = this.activeItems().length;
|
10171
|
+
if (count > this.maxActiveItems()) {
|
10172
|
+
this.validationInputTarget.setCustomValidity(this.validationInputTarget.dataset.maxMessage);
|
10173
|
+
}
|
10174
|
+
}
|
10175
|
+
minActiveItems() {
|
10176
|
+
return parseInt(this.element.dataset.min, 10) || 0;
|
10177
|
+
}
|
10178
|
+
maxActiveItems() {
|
10179
|
+
return parseInt(this.element.dataset.max, 10) || Infinity;
|
10180
|
+
}
|
10181
|
+
resetPositions() {
|
10182
|
+
this.activeItems().forEach((item, index2) => {
|
10183
|
+
const positionInput = item.querySelector("input[name*='position']");
|
10184
|
+
if (positionInput) {
|
10185
|
+
positionInput.value = index2;
|
10186
|
+
}
|
10187
|
+
});
|
10188
|
+
}
|
10189
|
+
addItems(items) {
|
10190
|
+
items.forEach((item) => this.addItem(item));
|
10191
|
+
}
|
10192
|
+
addItem(item) {
|
10193
|
+
const currentItem = this.itemByBlobId(item.blobId);
|
10194
|
+
if (currentItem) {
|
10195
|
+
this.enableItem(currentItem);
|
10196
|
+
} else {
|
10197
|
+
this.createItem(item);
|
10198
|
+
}
|
10199
|
+
}
|
10200
|
+
togglePlaceholder() {
|
10201
|
+
if (this.activeItems().length > 0) {
|
10202
|
+
this.hidePlaceholder();
|
10203
|
+
} else {
|
10204
|
+
this.showPlaceholder();
|
10205
|
+
}
|
10206
|
+
}
|
10207
|
+
showPlaceholder() {
|
10208
|
+
this.placeholderTarget.classList.remove("d-none");
|
10209
|
+
}
|
10210
|
+
hidePlaceholder() {
|
10211
|
+
this.placeholderTarget.classList.add("d-none");
|
10212
|
+
}
|
10213
|
+
enableItem(item) {
|
10214
|
+
item.querySelector(`input[name*='_destroy']`).value = false;
|
10215
|
+
item.classList.remove("d-none");
|
10216
|
+
}
|
10217
|
+
createItem(item) {
|
10218
|
+
const template = this.templateTarget;
|
10219
|
+
const html = this.randomizeIds(template);
|
10220
|
+
this.thumbnailsTarget.insertAdjacentHTML("beforeend", html);
|
10221
|
+
const newItem = this.itemTargets.pop();
|
10222
|
+
newItem.querySelector(`input[name*="[blob_id]"]`).value = item.blobId;
|
10223
|
+
newItem.querySelector(`input[name*="[_destroy]"]`).value = false;
|
10224
|
+
const editButton = newItem.querySelector(`[data-media-target="editButton"]`);
|
10225
|
+
editButton.setAttribute("href", editButton.getAttribute("href").replace("$1", item.blobId));
|
10226
|
+
const oldThumbnail = newItem.querySelector(".h-thumbnail");
|
10227
|
+
const newThumbnail = item.thumbnail.cloneNode(true);
|
10228
|
+
oldThumbnail.parentNode.replaceChild(newThumbnail, oldThumbnail);
|
10229
|
+
}
|
10230
|
+
randomizeIds(template) {
|
10231
|
+
const regex = new RegExp(template.dataset.templateIdRegex, "g");
|
10232
|
+
const randomNumber = Math.floor(1e8 + Math.random() * 9e8);
|
10233
|
+
return template.innerHTML.replace(regex, randomNumber);
|
10234
|
+
}
|
10235
|
+
removeAllItems() {
|
10236
|
+
this.removeItems(this.itemTargets);
|
10237
|
+
}
|
10238
|
+
removeItems(items) {
|
10239
|
+
items.forEach((item) => {
|
10240
|
+
this.removeItem(item);
|
10241
|
+
});
|
10242
|
+
}
|
10243
|
+
removeItem(item) {
|
10244
|
+
item.querySelector(`input[name*='_destroy']`).value = 1;
|
10245
|
+
item.classList.add("d-none");
|
10246
|
+
this.resetPositions();
|
10247
|
+
this.syncIds();
|
10248
|
+
this.togglePlaceholder();
|
10249
|
+
}
|
10250
|
+
itemByBlobId(blobId) {
|
10251
|
+
return this.itemTargets.find((item) => {
|
10252
|
+
return item.querySelector(`input[name*='blob_id']`).value === blobId;
|
10253
|
+
});
|
10254
|
+
}
|
10255
|
+
activeItems() {
|
10256
|
+
return this.itemTargets.filter((item) => {
|
10257
|
+
return item.querySelector(`input[name$='[_destroy]']`).value === "false";
|
10258
|
+
});
|
10259
|
+
}
|
10260
|
+
activeIds() {
|
10261
|
+
return this.activeItems().map((item) => {
|
10262
|
+
return item.querySelector(`input[name$='[blob_id]']`).value;
|
10263
|
+
});
|
10264
|
+
}
|
10265
|
+
};
|
10266
|
+
|
10267
|
+
// app/assets/javascripts/headmin/controllers/media_modal_controller.js
|
10268
|
+
var media_modal_controller_default = class extends Controller {
|
10269
|
+
static get targets() {
|
10270
|
+
return ["idCheckbox", "item", "form", "selectButton", "placeholder", "count"];
|
10271
|
+
}
|
10272
|
+
connect() {
|
10273
|
+
this.validate();
|
10274
|
+
this.updateCount();
|
10275
|
+
}
|
10276
|
+
select() {
|
10277
|
+
this.dispatchSelectionEvent();
|
10278
|
+
}
|
10279
|
+
submitForm() {
|
10280
|
+
this.hidePlaceholder();
|
10281
|
+
this.triggerFormSubmission();
|
10282
|
+
}
|
10283
|
+
inputChange() {
|
10284
|
+
this.handleInputChange();
|
10285
|
+
this.updateCount();
|
10286
|
+
}
|
10287
|
+
hidePlaceholder() {
|
10288
|
+
this.placeholderTarget.classList.add("d-none");
|
10289
|
+
}
|
10290
|
+
handleInputChange() {
|
10291
|
+
this.validate();
|
10292
|
+
}
|
10293
|
+
dispatchSelectionEvent() {
|
10294
|
+
document.dispatchEvent(new CustomEvent("mediaSelectionSubmitted", {
|
10295
|
+
detail: {
|
10296
|
+
name: this.element.dataset.name,
|
10297
|
+
items: this.renderItemsForEvent(this.selectedItems())
|
10298
|
+
}
|
10299
|
+
}));
|
10300
|
+
}
|
10301
|
+
triggerFormSubmission() {
|
10302
|
+
this.formTarget.requestSubmit();
|
10303
|
+
}
|
10304
|
+
renderItemsForEvent(items) {
|
10305
|
+
return items.map((item) => this.renderItemForEvent(item));
|
10306
|
+
}
|
10307
|
+
renderItemForEvent(item) {
|
10308
|
+
return {
|
10309
|
+
blobId: item.querySelector('input[type="checkbox"]').value,
|
10310
|
+
thumbnail: item.querySelector(".h-thumbnail")
|
10311
|
+
};
|
10312
|
+
}
|
10313
|
+
selectedItems() {
|
10314
|
+
return this.itemTargets.filter((item) => {
|
10315
|
+
const checkbox = item.querySelector('input[type="checkbox"]');
|
10316
|
+
return checkbox.checked;
|
10317
|
+
});
|
10318
|
+
}
|
10319
|
+
selectedItemsCount() {
|
10320
|
+
return this.selectedItems().length;
|
10321
|
+
}
|
10322
|
+
minSelectedItems() {
|
10323
|
+
return parseInt(this.element.dataset.min, 10) || 0;
|
10324
|
+
}
|
10325
|
+
maxSelectedItems() {
|
10326
|
+
return parseInt(this.element.dataset.max, 10) || Infinity;
|
10327
|
+
}
|
10328
|
+
validate() {
|
10329
|
+
if (this.isValid()) {
|
10330
|
+
this.enableSelectButton();
|
10331
|
+
} else {
|
10332
|
+
this.disableSelectButton();
|
10333
|
+
}
|
10334
|
+
}
|
10335
|
+
enableSelectButton() {
|
10336
|
+
this.selectButtonTarget.removeAttribute("disabled");
|
10337
|
+
}
|
10338
|
+
disableSelectButton() {
|
10339
|
+
this.selectButtonTarget.setAttribute("disabled", "");
|
10340
|
+
}
|
10341
|
+
isValid() {
|
10342
|
+
const count = this.selectedItemsCount();
|
10343
|
+
return count >= this.minSelectedItems() && count <= this.maxSelectedItems();
|
10344
|
+
}
|
10345
|
+
updateCount() {
|
10346
|
+
this.countTarget.innerHTML = this.idCheckboxTargets.filter((checkbox) => checkbox.checked).length;
|
10347
|
+
}
|
10348
|
+
};
|
10349
|
+
|
10014
10350
|
// node_modules/@popperjs/core/lib/index.js
|
10015
10351
|
var lib_exports = {};
|
10016
10352
|
__export(lib_exports, {
|
@@ -15081,6 +15417,9 @@ var popup_controller_default = class extends Controller {
|
|
15081
15417
|
});
|
15082
15418
|
}
|
15083
15419
|
handleOutsideClick(event) {
|
15420
|
+
const itemRemoved = !document.body.contains(event.target);
|
15421
|
+
if (itemRemoved)
|
15422
|
+
return;
|
15084
15423
|
const inPopup = event.target.closest('[data-popup-target="popup"]') !== null;
|
15085
15424
|
const inButton = event.target.closest('[data-popup-target="button"]') !== null;
|
15086
15425
|
const openPopup = document.querySelector('[data-popup-target="popup"]:not(.closed)');
|
@@ -15151,6 +15490,14 @@ var redactorx_controller_default = class extends Controller {
|
|
15151
15490
|
}
|
15152
15491
|
};
|
15153
15492
|
|
15493
|
+
// app/assets/javascripts/headmin/controllers/remote_modal_controller.js
|
15494
|
+
var remote_modal_controller_default = class extends Controller {
|
15495
|
+
connect() {
|
15496
|
+
this.modal = new Modal(this.element);
|
15497
|
+
this.modal.show();
|
15498
|
+
}
|
15499
|
+
};
|
15500
|
+
|
15154
15501
|
// app/assets/javascripts/headmin/controllers/repeater_controller.js
|
15155
15502
|
var repeater_controller_default = class extends Controller {
|
15156
15503
|
static get values() {
|
@@ -15305,11 +15652,11 @@ var select_controller_default = class extends Controller {
|
|
15305
15652
|
// app/assets/javascripts/headmin/controllers/table_actions_controller.js
|
15306
15653
|
var table_actions_controller_default = class extends Controller {
|
15307
15654
|
static get targets() {
|
15308
|
-
return ["wrapper", "form", "select", "method", "button", "
|
15655
|
+
return ["wrapper", "form", "select", "method", "button", "idInput", "counter"];
|
15309
15656
|
}
|
15310
15657
|
connect() {
|
15311
15658
|
this.wrapperTarget.addEventListener("idSelectionChanged", (event) => {
|
15312
|
-
this.
|
15659
|
+
this.updateIdInput(event.detail.ids);
|
15313
15660
|
this.updateCounter(event.detail.count);
|
15314
15661
|
this.toggleCounter(event.detail.count);
|
15315
15662
|
});
|
@@ -15321,16 +15668,21 @@ var table_actions_controller_default = class extends Controller {
|
|
15321
15668
|
this.updateFormDataAttributes();
|
15322
15669
|
this.enableButton();
|
15323
15670
|
}
|
15324
|
-
|
15325
|
-
|
15326
|
-
|
15327
|
-
|
15328
|
-
this.addId(id);
|
15329
|
-
});
|
15671
|
+
updateIdInput(ids) {
|
15672
|
+
if (ids == null) {
|
15673
|
+
this.disableIdInput();
|
15674
|
+
this.idInputTarget.value = "";
|
15330
15675
|
} else {
|
15331
|
-
this.
|
15676
|
+
this.enableIdInput();
|
15677
|
+
this.idInputTarget.value = `in:${ids.join(",")}`;
|
15332
15678
|
}
|
15333
15679
|
}
|
15680
|
+
disableIdInput() {
|
15681
|
+
this.idInputTarget.removeAttribute("name");
|
15682
|
+
}
|
15683
|
+
enableIdInput() {
|
15684
|
+
this.idInputTarget.setAttribute("name", "id");
|
15685
|
+
}
|
15334
15686
|
updateCounter(count) {
|
15335
15687
|
let htmlString = "";
|
15336
15688
|
switch (count) {
|
@@ -15385,16 +15737,6 @@ var table_actions_controller_default = class extends Controller {
|
|
15385
15737
|
enableButton() {
|
15386
15738
|
this.buttonTarget.removeAttribute("disabled");
|
15387
15739
|
}
|
15388
|
-
addId(id) {
|
15389
|
-
const template = this.idInputTemplateTarget;
|
15390
|
-
const input = template.innerHTML.replace(/ID/g, id);
|
15391
|
-
this.formTarget.insertAdjacentHTML("afterbegin", input);
|
15392
|
-
}
|
15393
|
-
removeIds() {
|
15394
|
-
this.idTargets.forEach((input) => {
|
15395
|
-
this.formTarget.removeChild(input);
|
15396
|
-
});
|
15397
|
-
}
|
15398
15740
|
};
|
15399
15741
|
|
15400
15742
|
// app/assets/javascripts/headmin/controllers/table_controller.js
|
@@ -15500,6 +15842,34 @@ var table_controller_default = class extends Controller {
|
|
15500
15842
|
}
|
15501
15843
|
};
|
15502
15844
|
|
15845
|
+
// app/assets/javascripts/headmin/controllers/textarea_controller.js
|
15846
|
+
var textarea_controller_default = class extends Controller {
|
15847
|
+
static get targets() {
|
15848
|
+
return ["textarea", "count"];
|
15849
|
+
}
|
15850
|
+
connect() {
|
15851
|
+
this.update();
|
15852
|
+
}
|
15853
|
+
update() {
|
15854
|
+
this.resize();
|
15855
|
+
this.updateCount();
|
15856
|
+
}
|
15857
|
+
resize() {
|
15858
|
+
this.textareaTarget.style.height = "auto";
|
15859
|
+
this.textareaTarget.setAttribute("style", "height:" + this.textareaTarget.scrollHeight + "px;overflow-y:hidden;");
|
15860
|
+
}
|
15861
|
+
updateCount() {
|
15862
|
+
if (this.textareaTarget.getAttribute("maxlength")) {
|
15863
|
+
this.updateCountLength();
|
15864
|
+
}
|
15865
|
+
}
|
15866
|
+
updateCountLength() {
|
15867
|
+
const current_length = this.textareaTarget.value.length;
|
15868
|
+
const maximum_length = this.textareaTarget.getAttribute("maxlength");
|
15869
|
+
this.countTarget.textContent = `${current_length}/${maximum_length}`;
|
15870
|
+
}
|
15871
|
+
};
|
15872
|
+
|
15503
15873
|
// app/assets/javascripts/headmin/index.js
|
15504
15874
|
var Headmin = class {
|
15505
15875
|
static start() {
|
@@ -15510,16 +15880,21 @@ var Headmin = class {
|
|
15510
15880
|
Stimulus.register("dropzone", dropzone_controller_default);
|
15511
15881
|
Stimulus.register("file-preview", file_preview_controller_default);
|
15512
15882
|
Stimulus.register("filter", filter_controller_default);
|
15883
|
+
Stimulus.register("filter-row", filter_row_controller_default);
|
15513
15884
|
Stimulus.register("filters", filters_controller_default);
|
15514
15885
|
Stimulus.register("flatpickr", flatpickr_controller_default);
|
15515
15886
|
Stimulus.register("hello", hello_controller_default);
|
15887
|
+
Stimulus.register("media", media_controller_default);
|
15888
|
+
Stimulus.register("media-modal", media_modal_controller_default);
|
15516
15889
|
Stimulus.register("notification", notification_controller_default);
|
15517
15890
|
Stimulus.register("popup", popup_controller_default);
|
15518
15891
|
Stimulus.register("redactorx", redactorx_controller_default);
|
15892
|
+
Stimulus.register("remote-modal", remote_modal_controller_default);
|
15519
15893
|
Stimulus.register("repeater", repeater_controller_default);
|
15520
15894
|
Stimulus.register("select", select_controller_default);
|
15521
15895
|
Stimulus.register("table", table_controller_default);
|
15522
15896
|
Stimulus.register("table-actions", table_actions_controller_default);
|
15897
|
+
Stimulus.register("textarea", textarea_controller_default);
|
15523
15898
|
}
|
15524
15899
|
};
|
15525
15900
|
export {
|
@@ -23,11 +23,85 @@
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
26
|
+
.h-filter-row {
|
27
|
+
padding: 0.5rem 0 0.5rem 0;
|
28
|
+
position: relative;
|
29
|
+
flex-wrap: unset;
|
30
|
+
display: flex;
|
31
|
+
gap: 10px;
|
32
|
+
|
33
|
+
&:first-child {
|
34
|
+
padding-top: 0
|
35
|
+
}
|
36
|
+
|
37
|
+
&:hover {
|
38
|
+
.h-filter-add-input, .h-filter-remove-input {
|
39
|
+
display: block;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
input, select:not(.h-filter-operator) {
|
44
|
+
min-width: 200px;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
.h-filter-operator {
|
49
|
+
width: 62px;
|
50
|
+
}
|
51
|
+
|
52
|
+
.h-filter-conditional {
|
53
|
+
position: relative;
|
54
|
+
display: flex;
|
55
|
+
justify-content: center;
|
56
|
+
align-items: center;
|
57
|
+
|
58
|
+
select {
|
59
|
+
width: 50px;
|
60
|
+
}
|
61
|
+
|
62
|
+
&::before {
|
63
|
+
content: '';
|
64
|
+
position: absolute;
|
65
|
+
top: calc(50% - 1px);
|
66
|
+
left: 0;
|
67
|
+
width: calc(50% - 35px);
|
68
|
+
height: 1px;
|
69
|
+
background: $popover-border-color;
|
70
|
+
}
|
71
|
+
|
72
|
+
&::after {
|
73
|
+
content: '';
|
74
|
+
position: absolute;
|
75
|
+
top: calc(50% - 1px);
|
76
|
+
left: calc(50% + 35px);
|
77
|
+
width: calc(50% - 35px);
|
78
|
+
height: 1px;
|
79
|
+
background: $popover-border-color;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
26
83
|
.h-filter-remove {
|
27
84
|
border-left: 1px solid $gray-300;
|
28
85
|
padding-left: 8px;
|
29
86
|
margin-left: 2px;
|
87
|
+
|
30
88
|
i::before {
|
31
89
|
font-size: 0.8em;
|
32
90
|
}
|
91
|
+
}
|
92
|
+
|
93
|
+
.h-filter-add-input {
|
94
|
+
position: absolute !important;
|
95
|
+
top: calc(100% - 12px);
|
96
|
+
left: calc(50% - 17px);
|
97
|
+
z-index: 9;
|
98
|
+
display: none;
|
99
|
+
}
|
100
|
+
|
101
|
+
.h-filter-remove-input {
|
102
|
+
position: absolute !important;
|
103
|
+
top: calc(50% - 15px);
|
104
|
+
left: calc(100% - 4px);
|
105
|
+
z-index: 9;
|
106
|
+
display: none;
|
33
107
|
}
|