Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $(function () {

this.arr.push({ Id: id, Name: tagText });

let tagInput = this;

let tag = document.createElement('span');
tag.className = this.options.tagClass + ' ' + tagClass;
Expand All @@ -61,13 +60,13 @@ $(function () {
let closeIcon = document.createElement('a');
closeIcon.innerHTML = '×';

closeIcon.addEventListener('click', function (e) {
closeIcon.addEventListener('click', (e) => {
e.preventDefault();
let tag = this.parentNode;
let tag = e.currentTarget.parentNode;

let tagIndex = Array.from(tagInput.wrapper.childNodes).indexOf(tag);
let tagIndex = Array.from(this.wrapper.childNodes).indexOf(tag);
if (tagIndex !== -1) {
tagInput.deleteTag(tag, tagIndex);
this.deleteTag(tag, tagIndex);
Comment thread
plavoie-BC marked this conversation as resolved.
}
})

Expand All @@ -82,23 +81,21 @@ $(function () {
}

TagsInput.prototype.deleteTag = function (tag, i) {
let self = this;

if (this.arr[i] && this.arr[i].Name === 'Uncommon Tags') {
if (this.arr[i]?.Name === 'Uncommon Tags') {
abp.message.confirm('Are you sure you want to delete all the uncommon tags?')
.then(function (confirmed) {
.then((confirmed) => {
if (confirmed) {
tag.remove();
self.arr.splice(i, 1);
self.orignal_input.value = JSON.stringify(self.arr);
updateSelectedTagsInput(self.arr);
this.arr.splice(i, 1);
this.orignal_input.value = JSON.stringify(this.arr);
updateSelectedTagsInput(this.arr);
Comment thread
plavoie-BC marked this conversation as resolved.

// Expand input if no tags remain
if (self.arr.length === 0) {
self.input.classList.add('expanded');
if (this.arr.length === 0) {
this.input.classList.add('expanded');
}

return self;
return this;
}
});
} else {
Expand Down Expand Up @@ -134,10 +131,8 @@ $(function () {
}

TagsInput.prototype.addData = function (array) {
let plugin = this;

array.forEach(function (string) {
plugin.addTag(string);
array.forEach((string) => {
this.addTag(string);
})
return this;
}
Expand All @@ -154,14 +149,13 @@ $(function () {
this.orignal_input.removeAttribute('hidden');

delete this.orignal_input;
let self = this;

Object.keys(this).forEach(function (key) {
if (self[key] instanceof HTMLElement)
self[key].remove();
Object.keys(this).forEach((key) => {
if (this[key] instanceof HTMLElement)
this[key].remove();

if (key != 'options')
delete self[key];
delete this[key];
Comment thread
plavoie-BC marked this conversation as resolved.
});

this.initialized = false;
Expand Down Expand Up @@ -355,5 +349,5 @@ $(function () {
duplicate: false
}

window.TagsInput = TagsInput;
globalThis.PaymentTagsInput = TagsInput;
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(function () {
});

tagPaymentModal.onOpen(async function () {
let tagInput = new TagsInput({
let tagInput = new PaymentTagsInput({
selector: 'SelectedTags',
duplicate: false,
max: 50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ $(function () {

this.arr.push({ Id: id, Name: tagText });

let tagInput = this;

let tag = document.createElement('span');
tag.className = this.options.tagClass + ' ' + tagClass;
tag.innerText = tagText;
Expand All @@ -61,13 +59,13 @@ $(function () {
let closeIcon = document.createElement('a');
closeIcon.innerHTML = '×';

closeIcon.addEventListener('click', function (e) {
closeIcon.addEventListener('click', (e) => {
e.preventDefault();
let tag = this.parentNode;
let tag = e.currentTarget.parentNode;

let tagIndex = Array.from(tagInput.wrapper.childNodes).indexOf(tag);
let tagIndex = Array.from(this.wrapper.childNodes).indexOf(tag);
if (tagIndex !== -1) {
tagInput.deleteTag(tag, tagIndex);
this.deleteTag(tag, tagIndex);
Comment thread
plavoie-BC marked this conversation as resolved.
}
})

Expand All @@ -82,23 +80,21 @@ $(function () {
}

TagsInput.prototype.deleteTag = function (tag, i) {
let self = this;

if (this.arr[i] && this.arr[i].Name === 'Uncommon Tags') {
if (this.arr[i]?.Name === 'Uncommon Tags') {
abp.message.confirm('Are you sure you want to delete all the uncommon tags?')
.then(function (confirmed) {
.then((confirmed) => {
if (confirmed) {
tag.remove();
self.arr.splice(i, 1);
self.orignal_input.value = JSON.stringify(self.arr);
updateSelectedTagsInput(self.arr);
this.arr.splice(i, 1);
this.orignal_input.value = JSON.stringify(this.arr);
updateSelectedTagsInput(this.arr);
Comment thread
plavoie-BC marked this conversation as resolved.

// Expand input if no tags remain
if (self.arr.length === 0) {
self.input.classList.add('expanded');
if (this.arr.length === 0) {
this.input.classList.add('expanded');
}

return self;
return this;
}
});
} else {
Expand Down Expand Up @@ -134,10 +130,8 @@ $(function () {
}

TagsInput.prototype.addData = function (array) {
let plugin = this;

array.forEach(function (string) {
plugin.addTag(string);
array.forEach((string) => {
this.addTag(string);
})
return this;
}
Expand All @@ -154,14 +148,13 @@ $(function () {
this.orignal_input.removeAttribute('hidden');

delete this.orignal_input;
let self = this;

Object.keys(this).forEach(function (key) {
if (self[key] instanceof HTMLElement)
self[key].remove();
Object.keys(this).forEach((key) => {
if (this[key] instanceof HTMLElement)
this[key].remove();

if (key != 'options')
delete self[key];
delete this[key];
Comment thread
plavoie-BC marked this conversation as resolved.
});

this.initialized = false;
Expand Down Expand Up @@ -353,5 +346,5 @@ $(function () {
duplicate: false
}

window.TagsInput = TagsInput;
globalThis.TagsInput = TagsInput;
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@page
@using Newtonsoft.Json
@using Unity.Modules.Shared
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Volo.Abp.Authorization.Permissions

@model Unity.GrantManager.Web.Pages.ApplicationTags.ApplicationTagsModalModel
Expand Down Expand Up @@ -49,7 +48,14 @@
}
</abp-modal-body>
<abp-modal-footer>
<button class="btn btn-primary" data-busy-text="Saving..." type="submit" id="assignTagsModelSaveBtn">Save</button>
@if (await PermissionChecker.IsGrantedAsync(UnitySelector.Application.Tags.Create) || await PermissionChecker.IsGrantedAsync(UnitySelector.Application.Tags.Delete))
{
<button class="btn btn-primary" data-busy-text="Saving..." type="submit" id="assignTagsModelSaveBtn">Save</button>
}
else
{
<button class="btn btn-primary" data-busy-text="Saving..." type="submit" id="assignTagsModelSaveBtn" disabled>Save</button>
}
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Cancel</button>
</abp-modal-footer>
</abp-modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ $(function () {

userTagsInput.setSuggestions(suggestionsArray);
userTagsInput.addData(tagInputArray);
document.getElementById("user-tags-input").setAttribute("data-touched", "false");
document.getElementById("user-tags-input").dataset.touched = "false";
});
tagApplicationModal.onResult(function () {
abp.notify.success(
Expand Down
Loading