Skip to content

Commit

Permalink
set version: v0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kakenbok committed Nov 14, 2024
1 parent d84e29d commit 9ba202e
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 20 deletions.
5 changes: 5 additions & 0 deletions lib/es5/filter/ActionFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ export class ActionFilter {
constructor(action, filter, name, json) {
this._defaultValue = null;
this._options = [];
this._multiple = false;
this._requestFactory = null;
this._filter = filter;
this._name = name;
this._defaultValue = filter.deserializeDefaultValue(json.default || null);
this._hasDefaultValue = json.hasOwnProperty('default');
this._options = json.options || [];
this._multiple = json.multiple || false;
if (json.options_request) {
this._requestFactory = () => {
const requestAction = action.getApi().getAction(json.options_request.resource, json.options_request.action);
Expand Down Expand Up @@ -47,6 +49,9 @@ export class ActionFilter {
}
return null;
}
get multiple() {
return this._multiple;
}
valueToQuery(value) {
return this._filter.valueToQuery(value);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/es5/list/ListViewFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class ListViewFilter {
createOptionsRequest() {
return this._filter.createOptionsRequest();
}
get multiple() {
return this._filter.multiple;
}
get value() {
return this._value;
}
Expand Down
10 changes: 0 additions & 10 deletions lib/es5/list/ListViewFilterBag.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,4 @@ export class ListViewFilterBag extends Bag {
}
return filters;
}
toActionFilterValueBag() {
const filters = {};
for (const [name, filter] of this.entries()) {
const value = filter.value;
if (value !== undefined) {
filters[name] = value;
}
}
return filters;
}
}
9 changes: 4 additions & 5 deletions lib/es5/list/ListViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,14 @@ export class ListViewModel {
getFiltersFromHistory() {
if (this._historyKey) {
if (filterHistory.hasFilters(this._historyKey)) {
const filters = filterHistory.getFilters(this._historyKey);
const historyFilters = {};
for (const [name, filter] of filters.entries()) {
const filters = {};
for (const [name, filter] of filterHistory.getFilters(this._historyKey).entries()) {
const value = filter.value;
if (value !== undefined) {
historyFilters[name] = value;
filters[name] = value;
}
}
return historyFilters;
return filters;
}
}
return {};
Expand Down
3 changes: 3 additions & 0 deletions lib/types/filter/ActionFilter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ActionFilterJSON = {
default: ActionFilterValueType;
options?: ActionFilterOption[];
options_request?: ApiRequestJSON;
multiple?: boolean;
};
export type ActionFilterOption = {
value: unknown;
Expand All @@ -18,6 +19,7 @@ export declare class ActionFilter {
private _defaultValue;
private _hasDefaultValue;
private _options;
private _multiple;
private _requestFactory;
constructor(action: Action, filter: Filter, name: string, json: ActionFilterJSON);
get type(): string;
Expand All @@ -29,6 +31,7 @@ export declare class ActionFilter {
get options(): ActionFilterOption[];
hasOptionsRequest(): boolean;
createOptionsRequest(): ApiRequest | null;
get multiple(): boolean;
valueToQuery(value: ActionFilterValueType): string | undefined;
queryToValue(value: string): ActionFilterValueType | undefined;
serializeValue(value: ActionFilterValueType): ActionFilterValueType;
Expand Down
2 changes: 1 addition & 1 deletion lib/types/filter/ActionFilter.d.ts.map

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

1 change: 1 addition & 0 deletions lib/types/list/ListViewFilter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export declare class ListViewFilter {
get options(): unknown[];
hasOptionsRequest(): boolean;
createOptionsRequest(): ApiRequest | null;
get multiple(): boolean;
get value(): ActionFilterValueType;
set value(value: ActionFilterValueType);
setInternalValue(value: ActionFilterValueType, dispatchChange?: boolean): boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/types/list/ListViewFilter.d.ts.map

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

1 change: 0 additions & 1 deletion lib/types/list/ListViewFilterBag.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import { ActionFilterValueType } from '../filter/ActionFilter';
import { ListViewFilter } from './ListViewFilter';
export declare class ListViewFilterBag extends Bag<ListViewFilter> {
serialize(): BagEntries<ActionFilterValueType>;
toActionFilterValueBag(): BagEntries<ActionFilterValueType>;
}
//# sourceMappingURL=ListViewFilterBag.d.ts.map
2 changes: 1 addition & 1 deletion lib/types/list/ListViewFilterBag.d.ts.map

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@afeefa/api-resources-client",
"version": "0.2.6",
"version": "0.2.7",
"description": "",
"module": "lib/es5/index.js",
"typings": "lib/types/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions src/filter/ActionFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type ActionFilterJSON = {
default: ActionFilterValueType
options?: ActionFilterOption[]
options_request?: ApiRequestJSON
multiple?: boolean
}

type RequestFactory = (() => ApiRequest) | null
Expand All @@ -27,6 +28,7 @@ export class ActionFilter {
private _defaultValue: ActionFilterValueType = null
private _hasDefaultValue: boolean
private _options: ActionFilterOption[] = []
private _multiple: boolean = false
private _requestFactory: RequestFactory = null

constructor (action: Action, filter: Filter, name: string, json: ActionFilterJSON) {
Expand All @@ -35,6 +37,7 @@ export class ActionFilter {
this._defaultValue = filter.deserializeDefaultValue(json.default || null)
this._hasDefaultValue = json.hasOwnProperty('default')
this._options = json.options || []
this._multiple = json.multiple || false

if (json.options_request) {
this._requestFactory = (): ApiRequest => {
Expand Down Expand Up @@ -84,6 +87,10 @@ export class ActionFilter {
return null
}

public get multiple (): boolean {
return this._multiple
}

public valueToQuery (value: ActionFilterValueType): string | undefined {
return this._filter.valueToQuery(value)
}
Expand Down
4 changes: 4 additions & 0 deletions src/list/ListViewFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class ListViewFilter {
return this._filter.createOptionsRequest()
}

public get multiple (): boolean {
return this._filter.multiple
}

public get value (): ActionFilterValueType {
return this._value
}
Expand Down

0 comments on commit 9ba202e

Please sign in to comment.