Skip to content

Commit

Permalink
add filter criteria infos to ace completer
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoRoessner committed Oct 10, 2023
1 parent 1e8a3d7 commit 54de58c
Showing 1 changed file with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class EditSmartServiceTaskDialogComponent implements OnInit, AfterViewIni
that.setAceJsonCompleter(callback);
return;
case 'ace/mode/javascript':
completer.getCompletions(_, session, pos, ___, callback);
that.setAceJsCompleter(session, pos, callback);
return;
default:
console.error('unknown ace editor mode:', session.$modeId);
Expand Down Expand Up @@ -293,6 +293,65 @@ export class EditSmartServiceTaskDialogComponent implements OnInit, AfterViewIni
callback(null, completers);
}

private setAceJsCompleter(session: any, pos: any, callback: any){
let that = this;
completer.getCompletions(null, session, pos, null, function (_: any, completers: { caption: string, value: string, meta: string }[]) {
if (!completers) {
completers = [];
}

completers.push({
caption: 'filter criteria struct',
value: 'var criteria = '+JSON.stringify({
aspect_id: "",
device_class_id: "",
function_id: "",
interaction: ""
} as Criteria)+'/*remove unused fields*/',
meta: 'static'
})

that.functions.forEach(value => {
completers.push({
caption: 'function: '+value.name,
value: `"${value.id}"/*${value.name}*/`,
meta: 'static'
})
})

that.deviceClasses.forEach(value => {
completers.push({
caption: 'device-class: '+value.name,
value: `"${value.id}"/*${value.name}*/`,
meta: 'static'
})
})

that.nestedAspects.forEach((list, _) => {
list.forEach(value => {
completers.push({
caption: 'aspect: '+value.name,
value: `"${value.id}"/*${value.name}*/`,
meta: 'static'
})
})
})

let interactions: String[] = ["event", "request", "event+request"];
interactions.forEach(value => {
completers.push({
caption: 'interaction: '+value,
value: `"${value}"`,
meta: 'static'
})
})


callback(null, completers);
});
}


private setAceJsEditor(element: ElementRef<HTMLElement>, inputNamePrefix: string){
if(element) {
const editor = barceEdit(element.nativeElement);
Expand Down

0 comments on commit 54de58c

Please sign in to comment.