Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag loading #34096

Merged
merged 4 commits into from
Sep 16, 2022
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
4 changes: 2 additions & 2 deletions apps/systemtags/src/systemtagsfilelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
toggleSelect: true,
separator: ',',
query: _.bind(this._queryTagsAutocomplete, this),
minimumInputLength: 3,

id(tag) {
return tag.id
Expand Down Expand Up @@ -148,8 +149,7 @@
},

formatSelection(tag) {
return OC.SystemTags.getDescriptiveTag(tag)[0]
.outerHTML
return OC.SystemTags.getDescriptiveTag(tag).outerHTML
},

sortResults(results) {
Expand Down
16 changes: 8 additions & 8 deletions core/js/tests/specs/systemtags/systemtagsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
describe('OC.SystemTags tests', function() {
it('describes non existing tag', function() {
var $return = OC.SystemTags.getDescriptiveTag('23');
expect($return.text()).toEqual('Non-existing tag #23');
expect($return.hasClass('non-existing-tag')).toEqual(true);
expect($return.textContent).toEqual('Non-existing tag #23');
expect($return.classList.contains('non-existing-tag')).toEqual(true);
});

it('describes SystemTagModel', function() {
Expand All @@ -34,8 +34,8 @@ describe('OC.SystemTags tests', function() {
userVisible: true
});
var $return = OC.SystemTags.getDescriptiveTag(tag);
expect($return.text()).toEqual('Twenty Three');
expect($return.hasClass('non-existing-tag')).toEqual(false);
expect($return.textContent).toEqual('Twenty Three');
expect($return.classList.contains('non-existing-tag')).toEqual(false);
});

it('describes JSON tag object', function() {
Expand All @@ -45,8 +45,8 @@ describe('OC.SystemTags tests', function() {
userAssignable: true,
userVisible: true
});
expect($return.text()).toEqual('Fourty Two');
expect($return.hasClass('non-existing-tag')).toEqual(false);
expect($return.textContent).toEqual('Fourty Two');
expect($return.classList.contains('non-existing-tag')).toEqual(false);
});

it('scope', function() {
Expand All @@ -57,8 +57,8 @@ describe('OC.SystemTags tests', function() {
userAssignable: userAssignable,
userVisible: userVisible
});
expect($return.text()).toEqual(expectedText);
expect($return.hasClass('non-existing-tag')).toEqual(false);
expect($return.textContent).toEqual(expectedText);
expect($return.classList.contains('non-existing-tag')).toEqual(false);
}

testScope(true, true, 'Fourty Two');
Expand Down
19 changes: 11 additions & 8 deletions core/src/systemtags/systemtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,24 @@ import escapeHTML from 'escape-html'
/**
*
* @param {OC.SystemTags.SystemTagModel|Object|String} tag
* @returns {jQuery}
* @returns {HTMLElement}
*/
getDescriptiveTag: function(tag) {
if (_.isUndefined(tag.name) && !_.isUndefined(tag.toJSON)) {
tag = tag.toJSON()
}

var $span = document.createElement('span')

if (_.isUndefined(tag.name)) {
return $('<span>').addClass('non-existing-tag').text(
t('core', 'Non-existing tag #{tag}', {
$span.classList.add('non-existing-tag')
$span.textContent = t('core', 'Non-existing tag #{tag}', {
tag: tag
})
)
})
return $span
}

var $span = $('<span>')
$span.append(escapeHTML(tag.name))
$span.textContent = escapeHTML(tag.name)

var scope
if (!tag.userAssignable) {
Expand All @@ -62,7 +63,9 @@ import escapeHTML from 'escape-html'
scope = t('core', 'invisible')
}
if (scope) {
$span.append($('<em>').text(' (' + scope + ')'))
var $scope = document.createElement('em')
$scope.textContent = ' (' + scope + ')'
$span.appendChild($scope)
}
return $span
}
Expand Down
5 changes: 4 additions & 1 deletion core/src/systemtags/systemtagscollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
fetch: function(options) {
var self = this
options = options || {}
if (this.fetched || options.force) {
if (this.fetched || this.working || options.force) {
// directly call handler
if (options.success) {
options.success(this, null, options)
Expand All @@ -79,10 +79,13 @@
return Promise.resolve()
}

this.working = true

var success = options.success
options = _.extend({}, options)
options.success = function() {
self.fetched = true
self.working = false
if (success) {
return success.apply(this, arguments)
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/systemtags/systemtagsinputfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ import templateSelection from './templates/selection.handlebars'
return templateResult(_.extend({
renameTooltip: t('core', 'Rename'),
allowActions: this._allowActions,
tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null,
tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data).innerHTML : null,
isAdmin: this._isAdmin
}, data))
},
Expand All @@ -305,7 +305,7 @@ import templateSelection from './templates/selection.handlebars'
*/
_formatSelection: function(data) {
return templateSelection(_.extend({
tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null,
tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data).innerHTML : null,
isAdmin: this._isAdmin
}, data))
},
Expand Down Expand Up @@ -385,6 +385,7 @@ import templateSelection from './templates/selection.handlebars'
multiple: this._multiple,
toggleSelect: this._multiple,
query: _.bind(this._queryTagsAutocomplete, this),
minimumInputLength: 3,
id: function(tag) {
return tag.id
},
Expand Down
4 changes: 2 additions & 2 deletions dist/core-systemtags.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-systemtags.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/systemtags-systemtags.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/systemtags-systemtags.js.map

Large diffs are not rendered by default.