Skip to content

Commit

Permalink
Merge pull request #4354 from NateWr/i3594_ui_library
Browse files Browse the repository at this point in the history
#3594 Fix linting and syntax errors and remove unused .git…
  • Loading branch information
NateWr authored Jan 17, 2019
2 parents b1420da + eaef718 commit 36a76bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
1 change: 0 additions & 1 deletion js/.gitignore

This file was deleted.

24 changes: 10 additions & 14 deletions js/classes/VueRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @brief Registry and initialization class for Vue.js handlers
*/
export default {

/**
* Registry of all active vue instances
*/
Expand All @@ -29,10 +28,8 @@ export default {
* @param object The data object to pass to the controller. Can include
* configuration parameters, translatable strings and initial data.
*/
init: function (id, type, data) {

init: function(id, type, data) {
if (pkp.controllers[type] === undefined) {
console.log('No Vue of the type ' + type + ' could be found.');
return;
}

Expand All @@ -41,24 +38,23 @@ export default {
delete data._constants;
}

var args = _.extend({}, pkp.controllers[type],
{
el: '#' + id,
data: _.extend(pkp.controllers[type].data(), data, { id: id }),
}
);
var args = $.extend(true, {}, pkp.controllers[type], {
el: '#' + id,
data: $.extend(true, {}, pkp.controllers[type].data(), data, {id: id})
});

pkp.registry._instances[id] = new pkp.Vue(args);

// Register with a parent handler from the legacy JS framework, so that
// those componments can destroy a Vue instance when removing HTML code
var $parents = $(pkp.registry._instances[id].$el).parents();
$parents.each(function (i) {
$parents.each(function(i) {
if ($.pkp.classes.Handler.hasHandler($($parents[i]))) {
$.pkp.classes.Handler.getHandler($($parents[i]))
.handlerChildren_.push(pkp.registry._instances[id]);
$.pkp.classes.Handler.getHandler($($parents[i])).handlerChildren_.push(
pkp.registry._instances[id]
);
return false; // only attach to the closest parent handler
}
});
},
}
};
7 changes: 3 additions & 4 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ export default {
* @param int|array roles The role ID to look for (pkp.const.ROLE_ID...)
* @return bool
*/
userHasRole: function (roles) {

userHasRole: function(roles) {
if (!Array.isArray(roles)) {
roles = [roles];
}

var hasRole = false;
roles.forEach((role) => {
roles.forEach(role => {
if ($.pkp.currentUser.accessRoles.indexOf(role) > -1) {
hasRole = true;
}
});

return hasRole;
},
}
};

0 comments on commit 36a76bb

Please sign in to comment.