Add swap function for arrays. Add reorderElements in stakeholder service
This commit is contained in:
parent
333973aefd
commit
013ce7d5f4
|
@ -146,6 +146,11 @@ export class StakeholderService {
|
|||
return this.http.delete<any>(url + '/' + path.join('/') + '/delete' + params, CustomOptions.registryOptions());
|
||||
}
|
||||
|
||||
reorderElements(url: string, path: string[], ids: string[]): Observable<any> {
|
||||
path = HelperFunctions.encodeArray(path);
|
||||
return this.http.post<any>(url + '/' + path.join('/') + '/reorder', ids, CustomOptions.registryOptions());
|
||||
}
|
||||
|
||||
reorderIndicators(url: string, path: string[], reorder: Reorder, type: string = 'chart'): Observable<Indicator[]> {
|
||||
path = HelperFunctions.encodeArray(path);
|
||||
return this.http.post<Indicator[]>(url + '/' + path.join('/') + '/' + type + '/reorder', reorder, CustomOptions.registryOptions()).pipe(map(indicators => {
|
||||
|
|
|
@ -90,4 +90,8 @@ export class HelperFunctions {
|
|||
return sgd1.localeCompare(sdg2);
|
||||
}
|
||||
}
|
||||
|
||||
public static swap(array: any[], from, to) {
|
||||
array.splice(to, 0, array.splice(from, 1)[0]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue