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

Add constants module #62

Closed
zachmullen opened this issue Jan 21, 2019 · 1 comment
Closed

Add constants module #62

zachmullen opened this issue Jan 21, 2019 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zachmullen
Copy link
Member

One general purpose utility this library could provide would be some constants from core, such as AccessType and SortDir.

@zachmullen zachmullen added enhancement New feature or request good first issue Good for newcomers labels Jan 21, 2019
@zachmullen
Copy link
Member Author

There's a Vue mixin I've found myself using across multiple projects now that would make use of these constants:

/**
 * This mixin exposes helper methods for components that need to check that the current user has
 * a certain access level on a given resource.
 */
export const accessLevelChecker = {
  methods: {
    hasWriteAccess: resource => resource._accessLevel >= AccessType.WRITE,
    hasAdminAccess: resource => resource._accessLevel >= AccessType.ADMIN,
  },
};

Since it's small, central, and common, I think that mixin should also be a candidate for inclusion in this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant