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

feat: add ember-can for visibility rules #547

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions addon/abilities/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Ability } from "ember-can";

export default class CategoryAbility extends Ability {
get can() {
return true;
}
}
7 changes: 7 additions & 0 deletions addon/abilities/document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Ability } from "ember-can";

export default class DocumentAbility extends Ability {
get can() {
return true;
}
}
7 changes: 7 additions & 0 deletions addon/abilities/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Ability } from "ember-can";

export default class TagAbility extends Ability {
get can() {
return true;
}
}
108 changes: 57 additions & 51 deletions addon/components/document-upload-button.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<div
class="uk-height-1-1"
uk-form-custom
...attributes
>
<div class="uk-height-1-1" uk-form-custom ...attributes>
<UkButton
@color="primary"
@size="small"
Expand All @@ -15,55 +11,65 @@
</UkButton>

{{#if @category}}
<input
type="file"
multiple="multiple"
data-test-input
aria-label="Category name"
{{on "change" (perform this.upload @category)}}
/>
{{#if can "upload document" @category}}
<input
type="file"
multiple="multiple"
data-test-input
aria-label="Category name"
{{on "change" (perform this.upload @category)}}
/>
{{/if}}
{{else}}
<Drop @width="uk-with-medium" as |Item|>
{{#each this.categories.records as |category|}}
<Item uk-form-custom data-test-upload-category>
<input
type="file"
multiple="multiple"
data-test-input
aria-label="file input"
{{on "change" (perform this.upload category)}}
/>
<FaIcon
@prefix="far"
@icon="folder"
@size="2x"
class="uk-margin-small-right"
data-test-folder-icon
{{set-style color=category.color}}
/>
{{category.name}}
</Item>
{{#if category.children.length}}
{{#each category.children as |child|}}
<Item class="item--indent" uk-form-custom data-test-upload-category>
<input
type="file"
multiple="multiple"
data-test-input
aria-label="file input"
{{on "change" (perform this.upload child)}}
/>
<FaIcon
@prefix="far"
@icon="folder"
@size="2x"
class="uk-margin-small-right"
data-test-folder-icon
{{set-style color=child.color}}
/>
{{child.name}}
</Item>
{{/each}}
{{#if can "upload to category" @category}}
<Item uk-form-custom data-test-upload-category>
<input
type="file"
multiple="multiple"
data-test-input
aria-label="file input"
{{on "change" (perform this.upload category)}}
/>
<FaIcon
@prefix="far"
@icon="folder"
@size="2x"
class="uk-margin-small-right"
data-test-folder-icon
{{set-style color=category.color}}
/>
{{category.name}}
</Item>
{{#if category.children.length}}
{{#each category.children as |child|}}
{{#if can "upload to category" @category}}
<Item
class="item--indent"
uk-form-custom
data-test-upload-category
>
<input
type="file"
multiple="multiple"
data-test-input
aria-label="file input"
{{on "change" (perform this.upload child)}}
/>
<FaIcon
@prefix="far"
@icon="folder"
@size="2x"
class="uk-margin-small-right"
data-test-folder-icon
{{set-style color=child.color}}
/>
{{child.name}}
</Item>
{{/if}}
{{/each}}
{{/if}}
{{/if}}
{{else}}
<span data-test-no-categories>
Expand Down
2 changes: 1 addition & 1 deletion addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class EmberAlexandriaEngine extends Engine {
Resolver = Resolver;

dependencies = {
services: ["session", "intl", "notification", "config"],
services: ["abilities", "session", "intl", "notification", "config"],
};
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@glimmer/tracking": "^1.1.2",
"animate-css-grid": "^1.5.1",
"ember-auto-import": "^2.6.3",
"ember-can": "^4.2.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-composable-helpers": "^5.0.0",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class App extends Application {
"ember-alexandria": {
dependencies: {
services: [
"abilities",
"session",
"intl",
"notification",
Expand Down
Loading