... | ... | @@ -30,7 +30,13 @@ Catalinker uses [Ractive.js](http://www.ractivejs.org/) web framework, developed |
|
|
### main.js
|
|
|
Most of the functionality in Catalinker is in main.js. It has grown from its humble beginnings in the old catalinker mentioned earlier to a quite large chunk of javascript code. Some parts and functions are more complex than others, and cater for more than one concern. No doubt should the file be divided into smaller modules and perhaps utilize Ractive's component support, but because of the incremental nature of the development process followed, and perhaps laziness, it has not come to this yet. However, most functions are kept small and with descriptive names, and the structure is roughly the same as from the beginning, only with more features added.
|
|
|
|
|
|
The core principle when editing RDF data with Catalinker is that "input" objects at some level in the application data tree structure are [two-way bound](http://docs.ractivejs.org/latest/two-way-binding) to html input fields, laid out according to the configuration. More precisely; it is the "input" objects' "current" value that is bound and shown in the input field, whereas the previous value is kept as "old". Whenever a field loses focus after it has been edited by the user, an event handler kicks in and compares the old with the current value, and when a change has taken place, a patch is created. The patch contains a delete operation for the old value and an add operation of the current one. This is conveyed to the back end as an HTTP PATCH, which removes the outdated RDF triple and inserts a new one for the updated value.
|
|
|
The core principle when editing RDF data with Catalinker is that "input" objects at some level in the application data tree structure are [two-way bound](http://docs.ractivejs.org/latest/two-way-binding) to html input fields, laid out according to the configuration. More precisely; it is the "input" objects' "current" value that is bound and shown in the input field, whereas the previous value is kept invisibly as "old". Whenever a field loses focus after it has been edited by the user, an event handler kicks in and compares the old with the current value, and when a change has taken place, a patch is created. The patch contains a delete operation for the old value and an add operation of the current one. This is conveyed to the back end as an HTTP PATCH, which removes the outdated RDF triple and inserts a new one for the updated value.
|
|
|
|
|
|
A number of variations of this theme are used for different types of inputs e.g.:
|
|
|
* Select value from set of predefined values
|
|
|
* Search for other resources, where the input's value is an uri, but a displayValue field of the input object holds the name or label of the referred resource
|
|
|
* Compound inputs; groups of any types of inputs that are saved as one
|
|
|
* Inputs not saved as data, but used for looking up internal and external data.
|
|
|
|
|
|
#### Outline
|
|
|
The outline of `main.js` is as follows:
|
... | ... | |