Add swap function for arrays. Add reorderElements in stakeholder service

This commit is contained in:
Konstantinos Triantafyllou 2022-07-14 14:37:07 +03:00
parent 333973aefd
commit 013ce7d5f4
2 changed files with 9 additions and 0 deletions

View File

@ -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 => {

View File

@ -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]);
}
}