Skip to content

Commit

Permalink
feat(ui): show data from tags and types
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo committed Apr 8, 2022
1 parent 69a88c0 commit 5ac78e8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
40 changes: 27 additions & 13 deletions packages/ui/src/controller/QueryControl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import Filter from "sap/ui/model/Filter";
import FilterOperator from "sap/ui/model/FilterOperator";
export default class QueryControl {
Expand Down Expand Up @@ -34,27 +37,38 @@ export default class QueryControl {
operator: FilterOperator.Contains,
value1: value,
});
let typeFilters = [];
for (let i = 0; i < valueTypes.length; i++) {
let typeFilter = new Filter({
path: "type",
operator: FilterOperator.Contains,
value1: valueTypes[i],
});
typeFilters.push(typeFilter);
}
const typeFilter = new Filter({
filters: typeFilters,
const tagsFilter = new Filter(
// currently types and tags are both in tags, may need to differ in future
"ui5-community/tags",
function (array) {
// check if the array contains values of another array
return valueTypes.some(function (value) {
return array.indexOf(value) > -1;
});
}.bind(this)
);
const typesFilter = new Filter(
// currently types and tags are both in tags, may need to differ in future
"ui5-community/types",
function (array) {
// check if the array contains values of another array
return valueTypes.some(function (value) {
return array.indexOf(value) > -1;
});
}.bind(this)
);
const typesTagsFilter = new Filter({
filters: [tagsFilter, typesFilter],
and: false,
});
const searchFilter = new Filter({
filters: [nameFilter, descFilter],
and: false,
});
if (typeFilters.length > 0) {
if (valueTypes.length > 0) {
listBinding.filter(
new Filter({
filters: [searchFilter, typeFilter],
filters: [searchFilter, typesTagsFilter],
and: true,
})
);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/model/data.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ui/src/view/Main.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<content>
<FlexBox id="_IDGenFlexBox2" direction="Column" alignItems="{= ${device>/system/phone} === true ? 'Inherit' : 'Center' }" justifyContent="Center">
<MultiInput startSuggestion="0" placeholder="Search for..." class="enlargeSearchfield sapUiMediumMarginTopBottom" id="multiInput" width="100%" liveChange=".liveSearch" tokenUpdate=".onUpdateToken" showValueHelp="false" value="{settings>/search}" suggestionItems="{
path: 'data>/types/'
path: 'data>/tags/'
}">
<core:Item key="{data>name}" text="{data>name}" />
<layoutData>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/view/Tags.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
xmlns="sap.m"
xmlns:core="sap.ui.core">
<List id="_IDGenList1" headerText="Tags" mode="None" items="{path: 'data>/types/'}" width="{= ${device>/system/phone} === true ? '' : '800px' }">
<List id="_IDGenList1" headerText="Tags" mode="None" items="{path: 'data>/tags/'}" width="{= ${device>/system/phone} === true ? '' : '800px' }">
<ObjectListItem
title="{data>name}"
type="Inactive"
Expand Down

0 comments on commit 5ac78e8

Please sign in to comment.