Skip to content

Commit

Permalink
Option to load more items in event type tree
Browse files Browse the repository at this point in the history
  • Loading branch information
jazdw committed Jun 30, 2020
1 parent 61c7fa6 commit a678b9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ma-tree-view items="$ctrl.typesPromise" item-id="$item.typeId" item-children="$item.loadChildren()" item-has-children="$item.hasChildren()"
<ma-tree-view items="$ctrl.typesPromise" item-id="$item.typeId" item-children="$item.loadChildren($limit, $offset)" item-has-children="$item.hasChildren()"
item-expanded="$ctrl.hasSelectedCount($item.type)"><!-- no space
--><md-checkbox ng-if="$item.handleable()" ng-click="$event.stopPropagation()" ng-disabled="$context.parent.item && $ctrl.selected.has($context.parent.item.type)"
ng-init="checked = $ctrl.selectedGetterSetter($item.type)" ng-model="checked" ng-model-options="{getterSetter: true}" ma-form-exclude>
Expand Down
19 changes: 10 additions & 9 deletions UI/web-src/ngMango/services/EventTypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ function eventTypeProvider() {

this.$get = eventTypeFactory;

eventTypeFactory.$inject = ['maRestResource', 'maRqlBuilder', 'maUtil', '$filter'];
function eventTypeFactory(RestResource, RqlBuilder, Util, $filter) {
eventTypeFactory.$inject = ['maRestResource', 'maRqlBuilder', 'maUtil'];
function eventTypeFactory(RestResource, RqlBuilder, Util) {

const orderBy = $filter('orderBy');
const eventTypeOptionsMap = new Map();

/**
Expand Down Expand Up @@ -247,16 +246,14 @@ function eventTypeProvider() {
return false;
}

loadChildren() {
loadChildren(limit, offset) {
const eventType = this.type;
return this.constructor.list({
eventType: eventType.eventType,
subType: this.supportsSubtype ? eventType.subType || undefined : null,
referenceId1: eventType.referenceId1,
referenceId2: eventType.referenceId2
}).then(items => {
return orderBy(items, this.orderBy || 'description');
});
}, limit, offset);
}

getSource() {
Expand All @@ -267,8 +264,12 @@ function eventTypeProvider() {
return this.description;
}

static list(eventType, opts = {}) {
return this.query(eventType, null, opts);
static list(eventType, limit, offset = 0, opts = {}) {
const builder = this.buildQuery(eventType).sort('description');
if (Number.isFinite(limit)) {
builder.limit(limit, offset);
}
return builder.query(opts);
}

static buildQuery(eventType) {
Expand Down

0 comments on commit a678b9d

Please sign in to comment.