Merge pull request #7632 from artoscinote/ma_SCI_10687

Fix reloading of tags on canvas [SCI-10687]
This commit is contained in:
Martin Artnik 2024-06-06 12:03:15 +02:00 committed by GitHub
commit bbc5b777df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View file

@ -8,8 +8,8 @@ const app = createApp({
data() { data() {
return { return {
myModuleParams: null, myModuleParams: null,
myModuleUrl: null,
tagsModalOpen: false, tagsModalOpen: false,
tagsUrl: null
}; };
}, },
mounted() { mounted() {
@ -20,6 +20,7 @@ const app = createApp({
}, },
methods: { methods: {
open(myModuleUrl) { open(myModuleUrl) {
this.myModuleUrl = myModuleUrl;
$.ajax({ $.ajax({
url: myModuleUrl, url: myModuleUrl,
type: 'GET', type: 'GET',
@ -32,6 +33,7 @@ const app = createApp({
}, },
close() { close() {
this.myModuleParams = null; this.myModuleParams = null;
this.myModuleUrl = null;
this.tagsModalOpen = false; this.tagsModalOpen = false;
}, },
syncTags(tags) { syncTags(tags) {
@ -52,15 +54,13 @@ const app = createApp({
// Canvas // Canvas
if ($('#canvas-container').length) { if ($('#canvas-container').length) {
$.ajax({ $.ajax({
url: this.tagsUrl, url: this.myModuleUrl,
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
success(data) { success(data) {
$.each(data.my_modules, (index, myModule) => { $(`div.panel[data-module-id='${data.data.id}']`)
$(`div.panel[data-module-id='${myModule.id}']`)
.find('.edit-tags-link') .find('.edit-tags-link')
.html(myModule.tags_html); .html(data.data.attributes.tags_html);
});
} }
}); });
} }

View file

@ -19,6 +19,7 @@ module Lists
status status
designated_users designated_users
tags tags
tags_html
comments comments
due_date_formatted due_date_formatted
permissions permissions
@ -142,6 +143,15 @@ module Lists
end end
end end
def tags_html
# legacy canvas support
ApplicationController.new.render_to_string(
partial: 'canvas/tags',
locals: { my_module: object },
formats: :html
)
end
def comments def comments
@user = scope[:user] || @instance_options[:user] @user = scope[:user] || @instance_options[:user]
{ {