JAVASCRIPT   70

load.js

Guest on 29th July 2021 12:57:55 AM

  1. /**
  2.  * @file js/load.js
  3.  *
  4.  * Copyright (c) 2014-2020 Simon Fraser University
  5.  * Copyright (c) 2000-2020 John Willinsky
  6.  * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
  7.  *
  8.  * @brief Common configuration for building the Javascript package
  9.  */
  10.  
  11. // Vue lib and custom mixins
  12. import Vue from 'vue';
  13. import GlobalMixins from '@/mixins/global.js';
  14. import VTooltip from 'v-tooltip';
  15. import VueScrollTo from 'vue-scrollto';
  16.  
  17. // Helper for initializing and tracking Vue controllers
  18. import VueRegistry from './classes/VueRegistry.js';
  19.  
  20. Vue.use(VTooltip, {defaultTrigger: 'click'});
  21. Vue.use(VueScrollTo);
  22. Vue.mixin(GlobalMixins);
  23.  
  24. export default {
  25.         Vue: Vue,
  26.         registry: VueRegistry,
  27.         eventBus: new Vue(),
  28.         const: {},
  29.         /**
  30.          * Helper function to determine if the current user has a role
  31.          *
  32.          * @param int|array roles The role ID to look for (pkp.const.ROLE_ID...)
  33.          * @return bool
  34.          */
  35.         userHasRole: function(roles) {
  36.                 if (!Array.isArray(roles)) {
  37.                         roles = [roles];
  38.                 }
  39.  
  40.                 var hasRole = false;
  41.                 roles.forEach(role => {
  42.                         if ($.pkp.currentUser.accessRoles.indexOf(role) > -1) {
  43.                                 hasRole = true;
  44.                         }
  45.                 });
  46.  
  47.                 return hasRole;
  48.         }
  49. };

Raw Paste


Login or Register to edit or fork this paste. It's free.