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

Fix: Allow custom types (fixes #103) #104

Merged
merged 17 commits into from
Jun 14, 2023
Merged
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
48 changes: 38 additions & 10 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,34 @@
"all": "All",
"document": "PDF",
"media": "Media",
"link": "Link"
"link": "Link",
"custom1": "Custom category 1",
"custom2": "Custom category 2",
"custom3": "Custom category 3",
"custom4": "Custom category 4",
"custom5": "Custom category 5",
"custom6": "Custom category 6",
"custom7": "Custom category 7",
"custom8": "Custom category 8",
"custom9": "Custom category 9",
"custom10": "Custom category 10"
StuartNicholls marked this conversation as resolved.
Show resolved Hide resolved
},
"_comment": "_filterAria is to provide accessibility support for assistive technologies",
"_filterAria": {
"allAria": "View all resources",
"documentAria": "View document resources",
"mediaAria": "View media resources",
"linkAria": "View resource links"
"linkAria": "View resource links",
"custom1Aria": "View custom category 1 links",
"custom2Aria": "View custom category 2 links",
"custom3Aria": "View custom category 3 links",
"custom4Aria": "View custom category 4 links",
"custom5Aria": "View custom category 5 links",
"custom6Aria": "View custom category 6 links",
"custom7Aria": "View custom category 7 links",
"custom8Aria": "View custom category 8 links",
"custom9Aria": "View custom category 9 links",
"custom10Aria": "View custom category 10 links"
},
"_resourcesItems": [
{
Expand All @@ -33,15 +53,19 @@
"_type": "media",
"title": "Adapt Learning YouTube Channel",
"description": "Fancy catching up on some Adapt material",
"_link": "https://www.youtube.com/channel/UCW8SlSFuCc--B66Gf9fAEcQ",
"_forceDownload": false
"_link": "https://www.youtube.com/channel/UCW8SlSFuCc--B66Gf9fAEcQ"
},
{
"_type": "link",
"title": "Community Site",
"description": "Select here to view our community site",
"_link": "https://community.adaptlearning.org",
"_forceDownload": false
"_link": "https://community.adaptlearning.org"
},
{
"_type": "custom1",
"title": "GitHub",
"description": "Select here to view the Adapt respository on GitHub",
"_link": "https://github.com/adaptlearning"
}
]
}
Expand All @@ -62,15 +86,19 @@
"_type": "media",
"title": "Adapt Learning YouTube Channel",
"description": "Fancy catching up on some Adapt material",
"_link": "https://www.youtube.com/channel/UCW8SlSFuCc--B66Gf9fAEcQ",
"_forceDownload": false
"_link": "https://www.youtube.com/channel/UCW8SlSFuCc--B66Gf9fAEcQ"
},
{
"_type": "link",
"title": "Community Site",
"description": "Select here to view our community site",
"_link": "https://community.adaptlearning.org",
"_forceDownload": false
"_link": "https://community.adaptlearning.org"
},
{
"_type": "custom1",
"title": "GitHub",
"description": "Select here to view the Adapt respository on GitHub",
"_link": "https://github.com/adaptlearning"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion js/ResourcesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default class ResourcesView extends Backbone.View {
const data = {
...this,
model: this.model.toJSON(),
resources: this.model.get('_resources')
resources: this.model.get('_resources'),
resourceTypes: this.model.get('_resourceTypes')
};
ReactDOM.render(<templates.resources {...data} />, this.el);

Expand Down
10 changes: 10 additions & 0 deletions js/adapt-contrib-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,19 @@ class Resources extends Backbone.Controller {
resources = resources.filter(resource => resource._isGlobal !== false);
}
model.set('_resources', resources);

this.setupTypes(model, resourcesData);

drawer.triggerCustomView(new ResourcesView({ model }).$el);
});
}

setupTypes(model, resourcesData) {
const configuredTypes = Object.keys(resourcesData._filterButtons).filter(type => type !== 'all');
const allTypes = [ 'all', ...configuredTypes ];
model.set('_resourceTypes', allTypes);
}

}

export default new Resources();
5 changes: 5 additions & 0 deletions less/resources.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
display: flex;
}

&__filter.has-extra-types &__filter-inner {
flex-wrap: wrap;
}

&__filter-btn {
flex-grow: 1;
white-space: nowrap;
}

html:not(.ie) &__filter-btn {
Expand Down
160 changes: 160 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,86 @@
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom1": {
"type": "string",
"default": "Custom category 1",
"title": "Custom category 1",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom2": {
"type": "string",
"default": "Custom category 2",
"title": "Custom category 2",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom3": {
"type": "string",
"default": "Custom category 3",
"title": "Custom category 3",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom4": {
"type": "string",
"default": "Custom category 4",
"title": "Custom category 4",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom5": {
"type": "string",
"default": "Custom category 5",
"title": "Custom category 5",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom6": {
"type": "string",
"default": "Custom category 6",
"title": "Custom category 6",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom7": {
"type": "string",
"default": "Custom category 7",
"title": "Custom category 7",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom8": {
"type": "string",
"default": "Custom category 8",
"title": "Custom category 8",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom9": {
"type": "string",
"default": "Custom category 9",
"title": "Custom category 9",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom10": {
"type": "string",
"default": "Custom category 10",
"title": "Custom category 10",
"inputType": "Text",
"validators": [],
"translatable": true
}
}
},
Expand Down Expand Up @@ -178,6 +258,86 @@
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom1Aria": {
"type": "string",
"default": "View custom category 1 links",
"title": "Custom category 1",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom2Aria": {
"type": "string",
"default": "View custom category 2 links",
"title": "Custom category 2",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom3Aria": {
"type": "string",
"default": "View custom category 3 links",
"title": "Custom category 3",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom4Aria": {
"type": "string",
"default": "View custom category 4 links",
"title": "Custom category 4",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom5Aria": {
"type": "string",
"default": "View custom category 5 links",
"title": "Custom category 5",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom6Aria": {
"type": "string",
"default": "View custom category 6 links",
"title": "Custom category 6",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom7Aria": {
"type": "string",
"default": "View custom category 7 links",
"title": "Custom category 7",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom8Aria": {
"type": "string",
"default": "View custom category 8 links",
"title": "Custom category 1",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom9Aria": {
"type": "string",
"default": "View custom category 9 links",
"title": "Custom category 9",
"inputType": "Text",
"validators": [],
"translatable": true
},
"custom10Aria": {
"type": "string",
"default": "View custom category 10 links",
"title": "Custom category 10",
"inputType": "Text",
"validators": [],
"translatable": true
}
}
},
Expand Down
Loading