Код: Выделить всё
def index
@tags = Tag.where(organization: @organization).order(:name)
@selected_tags = @tags.where(selected: true)
end
Код: Выделить всё
Delete Selected Tags
Create Tag
Select All/None
Name
Код: Выделить всё
Edit
Код: Выделить всё
function toggleTagSelection(organizationId, tagId, selected){
const data = {
id: tagId,
selected: selected
};
if(selected) {
selectedTags.push(tagId)
} else {
if(selectedTags.includes(tagId)){
index = selectedTags.indexOf(tagId)
selectedTags.splice(index, 1)
}
}
selectedTagsCountSpan.textContent = selectedTags.length;
documents = getSelectedTagsAssetCount(organizationId)
updateConfirmMessage(selectedTags.length, documents);
console.log("Data", data);
console.log("Selected Tags", selectedTags);
}
function getSelectedTagsAssetCount(organizationId) {
$.ajax({
url: `/organizations/${organizationId}/tags/selected_tags_assets_count`,
method: 'GET',
dataType: 'json',
data: {
selectedTags: selectedTags
},
error: function(e) {
console.error(e);
},
success: function(response) {
console.log("Associated Documents", response.associated_documents)
return response.associated_documents;
}
});
}
function updateConfirmMessage(tagsCount, documentsCount) {
const confirmMessage = `Are you sure you want to delete ${tagsCount} tag(s)? These tags are associated with ${documentsCount} asset(s). This action cannot be undone and will delete the tag and tag associations permanently.`;
deleteButton.setAttribute('data-confirm', confirmMessage);
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... -ajax-call
Мобильная версия