CRUD: Difference between revisions

From Wikisphere
Jump to navigation Jump to search
Subpages:
No edit summary
No edit summary
Line 100: Line 100:
4) template [[Template:Task action]], containing another pageproperties form, as mentioned
4) template [[Template:Task action]], containing another pageproperties form, as mentioned


5) The extension [https://www.mediawiki.org/wiki/Extension:IDProvider IDProvider] triggered from an hidden input in the same schema, and then used as <code>pagename-formula</code>
5) The templates [[Template:Extensions_list]] and [[Task_status_list]] (actually not a template) used in the form's dropdowns


6) The extension [https://www.mediawiki.org/wiki/Extension:VEForAll VEForAll] in order to display [https://www.mediawiki.org/wiki/Extension:VisualEditor VisualEditor] in the textarea
6) The extension [https://www.mediawiki.org/wiki/Extension:IDProvider IDProvider] triggered from an hidden input in the same schema, and then used as <code>pagename-formula</code>
 
7) The extension [https://www.mediawiki.org/wiki/Extension:VEForAll VEForAll] in order to display [https://www.mediawiki.org/wiki/Extension:VisualEditor VisualEditor] in the textarea





Revision as of 21:05, 30 December 2023

The following demonstrates the creation of a CRUD (create, read, update, delete) interface performed through a button opening a popup form, a pagepropertiesquery parser function that creates the table, and a template, namely Template:Task_action, rendered within the column "action", holding another form that edits the same schema (PagePropertiesSchema:Task) based on the data of the page with value {{{pagetitle}}}, where {{{pagetitle}}} is the title of the article related to each row of the generated table. (see the docs for other parameters)

The template is associated to the column "action" using the following wikitext

template?action=Task action

and all the properties of the row, as well as the article title, are available as named parameters.


The form also demostrates the use of the option target-slot = main that instructs the form to save the json data to the main slot of the target article, as you can see here. Such data can then be edited through the edit button in the action column, through the tab "Edit semantic" in the target article, or even manually through "edit source" in the target article, and the changes will be reflected in the table below.

The form also shows the integration of Extension:VEForAll in the comments field.


{{#pagepropertiesform: Task |title = Task |action = create |edit-page = |return-page = CRUD |view = popup |popup-size = large |css-class = |pagename-formula =CRUD/<id-increment> |target-slot = main |edit-freetext = false |edit-categories = false |edit-content-model = false |default-categories = |default-content-model = wikitext |layout-align = top |popup-help = true |submit-button-text = |layout = tabs |validate-button-text = }}



{{#pagepropertiesquery: CRUD/~ |schema=Task |?assignee |?extension |?status |?action |template?action=Task action |format=datatable }}


Here are the components to implement it.

1) Json-schema describing the form: PagePropertiesSchema:Task (created through the Schema builder)


2) parser function for the form popup

{{#pagepropertiesform: Task
|title = Task
|action = create
|edit-page = 
|return-page = CRUD
|view = popup
|popup-size = large
|css-class =
|pagename-formula =CRUD/<id-increment>
|target-slot = main
|edit-freetext = false	
|edit-categories = false
|edit-content-model = false
|default-categories = 
|default-content-model = wikitext
|layout-align = top
|popup-help = true 
|submit-button-text =
|layout = tabs
|validate-button-text =
}}


3) Parser function for the table


{{#pagepropertiesquery: [[CRUD/~]]
|schema=Task 
|?assignee
|?extension
|?status
|?action
|template?action=Task action
|format=datatable 
}}


4) template Template:Task action, containing another pageproperties form, as mentioned

5) The templates Template:Extensions_list and Task_status_list (actually not a template) used in the form's dropdowns

6) The extension IDProvider triggered from an hidden input in the same schema, and then used as pagename-formula

7) The extension VEForAll in order to display VisualEditor in the textarea


See also