Set auto completion on Ninox editor
Hello everyone,
I was fed up with always having to close the code editor to fetch the name of a field or table, so I set up the Ninox code editor to have an auto-completion function :
press ctrl+space on the editor to display the completion list.
The list contain all Ninox functions, data base table and fields for each table and global user functions :
Ninox uses CodeMirror to edit its code. This editor is very complete and I didn't have too much trouble adding autocomplete. It is a classic CodeMirror add-on and there are many examples of how to do it on the web. The CodeMirror documentation also helped me a lot.
I think it is easy to improve the syntax highlighting. I will try it later.
Because this code is long, I create GitHub repository with all code I did and published in this forum. You can download it here : https://github.com/JacquesTur/Ninext
To add the code on your application, you can copy the content of the completion.html file on GitHub and put it in on one formula :
html("
put the copy of code here
");
Or use the following code in your formula:
html(http("GET", "https://raw.githubusercontent.com/JacquesTur/Ninext/main/completion.html").result)
In this last solution, your application will have directly the last modifications of the code in real time, the improvement... but also the new bugs .
71 replies
-
Bonjour Jaques.
Excellent travail.
Ça facilite le scripting.
J'admire toujours ton travail.
Salutations
---
Hello Jaques.
Great work.
Makes scripting easier.
I always admire your work.
Greetings
Uwe -
I did a little promotion for your forum entry in the german forum:
https://forum.ninox.de/t/q6hbpkh-----
For all those who do a lot of scripting in Ninox, the following entry in the English Ninox forum is recommended:
https://forum.ninox.com/t/g9hbpzh/set-auto-completion-on-ninox-editor
and the corresponding GitHub page:
https://github.com/JacquesTur/NinextJaques had already programmed such a possibility for Ninox before the introduction of dynamic selection fields.
His work is always a highlight from my personal point of view.
--Greetings
UweG -
Hi there Jacques,
Could you explain this in a little more detail please. I am trying your second option by simply placing in a formula in a form. That does not seem right so I am not surprised it is not working. If you could advise where exactly I should place the "GET" example I would be grateful. Does it need to be added as a formula on every 'page' one wants this option?
-
Yes, just put the code in a formula and have it show up on the screen at least once. It is not necessary to put the formula on all the tables, just one.
I think I know what the problem is. I was in the process of making some changes and I think I mistakenly published a non-functional version on GitHub.
Could you try now to see if it works? -
This is awesome Jacques TUR . It's incredible that Ninox has not implemented some of the features that you have listed, especially search and replace. Do you know if Ninox is going to implement an add-on ability like import or require? That would be so much nicer than putting the code in a Formula field in an active table.
-
Great job Jacques, thanks for that!
Small note: "this.ID" is used in lines 1, 140 and 174 of badges.html. I had to change that to "this._id". -
Good evening to all,
Following today's webinar, I have modified the structure of the code to make it more easily improved.
At the same time, I added configuration parameters and a function call after the code initialization.The variable "configLoadModules" is used to define which modules should be loaded. Afterwards it will allow to parameterize these modules, like for example the colour of the bagdes.
The "afterLoadModules" function is called as soon as the code is initialized. It allows to display a message or to close the current window. In the example above, the window is automatically closed if you are not in database administration mode.
var configLoadModules := { completion: true, badges: true, evalJS: true }; function afterLoadModules() do if not isAdminMode() then closeRecord() end end; html(http("GET", "https://raw.githubusercontent.com/JacquesTur/Ninext/main/loadModules.html").result)
It is this code that must now be put in the initialization formula. The previous code I shared (.html file) is still available, but it will no longer be maintained or improved.
note: this new code introduces a new possibility: from the JavaScript, call a Ninox function located in a formula. This will allow events to be handled between HTML/JavaScript without going through the Rest API. More functions will come soon...
-
Hi Jacques -
I'm using the Mac app and I can't seem to get it to work. I'm copying the code into a html() function and when I press ctrl + space nothing happens. Do you know if it supposed to work in the Mac app?
-
What a fast response! I've copied the "new" completion.html into a formula field and still nothing happens. In another formula field when I type "select r" then press ctrl+space. I would think a submenu pops up, but nothing.
Am I doing it right?
-
Jacques – thank you so much for sharing your work! I've just had a chance to install it and it works brilliantly. I particularly like that Global formulae show in red! Brilliant work!
Content aside
-
14
Likes
- 2 yrs agoLast active
- 71Replies
- 1571Views
-
18
Following