Skip to content

Commit d623a10

Browse files
authored
Picklist all (#223)
* Provide /picklistAll as an alternative to /listAll. Returns the same data but intended only to be used for picklist population. Would enable permissions to be applied differently for that use case. * Provide getAllPicklistAttributes() as an alternative to getAllListAttributes(). Returns the same data but intended only to be used for picklist population. Would enable permissions to be applied differently for that use case.
1 parent 0f7037c commit d623a10

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/client/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ declare module fng {
759759
readRecord: (modelName: string, id: string, formName?: string) => angular.IHttpPromise<any>;
760760
getAll: (modelName: string, _options: any) => angular.IHttpPromise<any[]>;
761761
getAllListAttributes: (ref: string) => angular.IHttpPromise<ILookupItem[]>;
762+
getAllPickListAttributes: (ref: string) => angular.IHttpPromise<ILookupItem[]>;
762763
getPagedAndFilteredList: (
763764
modelName: string,
764765
options: IListQueryOptions

src/client/js/services/submissions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,14 @@ module fng.services {
130130
},
131131

132132
// return only the list attributes for ALL records in the given collection, returning ILookupItem[]
133+
// getAllPickListAttributes() is intended to be used to retrieve records for display in a picklist;
134+
// getAllListAttributes() for all other use cases
133135
getAllListAttributes: function (ref: string): angular.IHttpPromise<ILookupItem[]> {
134136
return $http.get(`/api/${ref}/listAll`, { cache: expCache });
135137
},
138+
getAllPickListAttributes: function (ref: string): angular.IHttpPromise<ILookupItem[]> {
139+
return $http.get(`/api/${ref}/picklistAll`, { cache: expCache });
140+
},
136141

137142
// return only the list attributes for records in the given collection that satisfy the given query conditions (filter, limit etc.)
138143
// return ILookupItem[] if options.concatenate is true, else the raw documents

src/server/data_form.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ export class FormsAngular {
150150
processArgs(this.options, [resourceName, this.collectionGet()])
151151
);
152152

153-
// return the List attributes for all records - used by record-handler's setUpLookupOptions() method, for cases
153+
// return the List attributes for all records. two endpoints that go through the same handler so permissions
154+
// can be applied differently for the two use cases. /listAll is intended for listing records on a page;
155+
// /picklistAll for listing them in a <select> or similar - used by record-handler's setUpLookupOptions() method, for cases
154156
// where there's a lookup that doesn't use the fngajax option
155157
this.app.get.apply(
156158
this.app,
@@ -159,6 +161,13 @@ export class FormsAngular {
159161
this.entityListAll(),
160162
])
161163
);
164+
this.app.get.apply(
165+
this.app,
166+
processArgs(this.options, [
167+
resourceName + "/picklistAll",
168+
this.entityListAll(),
169+
])
170+
);
162171

163172
// return the List attributes for a record - used by fng-ui-select
164173
this.app.get.apply(

0 commit comments

Comments
 (0)