2016-01-21 17:35:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function(OC) {
|
|
|
|
/**
|
|
|
|
* @namespace
|
|
|
|
*/
|
|
|
|
OC.SystemTags = {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {OC.SystemTags.SystemTagModel|Object|String} tag
|
|
|
|
* @return {jQuery}
|
|
|
|
*/
|
|
|
|
getDescriptiveTag: function(tag) {
|
|
|
|
if (_.isUndefined(tag.name) && !_.isUndefined(tag.toJSON)) {
|
|
|
|
tag = tag.toJSON();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_.isUndefined(tag.name)) {
|
|
|
|
return $('<span>').addClass('non-existing-tag').text(
|
|
|
|
t('core', 'Non-existing tag #{tag}', {
|
|
|
|
tag: tag
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-01-27 17:49:11 +03:00
|
|
|
var $span = $('<span>');
|
|
|
|
$span.append(escapeHTML(tag.name));
|
|
|
|
|
|
|
|
var scope;
|
|
|
|
if (!tag.userAssignable) {
|
2016-05-18 12:23:23 +03:00
|
|
|
scope = t('core', 'restricted');
|
2016-01-27 17:49:11 +03:00
|
|
|
}
|
|
|
|
if (!tag.userVisible) {
|
|
|
|
// invisible also implicitly means not assignable
|
|
|
|
scope = t('core', 'invisible');
|
|
|
|
}
|
|
|
|
if (scope) {
|
|
|
|
var $tag = $('<em>').text(' ' +
|
|
|
|
t('core', '({scope})', {
|
|
|
|
scope: scope
|
2016-01-21 17:35:15 +03:00
|
|
|
})
|
|
|
|
);
|
2016-01-27 17:49:11 +03:00
|
|
|
$span.append($tag);
|
|
|
|
}
|
2016-01-21 17:35:15 +03:00
|
|
|
return $span;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})(OC);
|
|
|
|
|