UNPKG

10.7 kBMarkdownView Raw
1# Path Framework
2
3[![Build Status](https://travis-ci.org/innovad/path.svg?branch=master)](https://travis-ci.org/innovad/path)
4
5Path Framework is developed at <a href="https://www.zhaw.ch/de/sml/institute-zentren/iwi/">Zurich University of Applied Sciences</a> (ZHAW) and used in several projects. It is an application framework and rendering engine that renders your application based on a technology-independent GUI model stored in JSON format. Either mock data or any backend REST service (node, Java) may be used with Path Framework.
6<br>
7<br>
8
9[![Alt text](https://img.youtube.com/vi/WxLKdviTm7A/0.jpg)](https://www.youtube.com/watch?v=WxLKdviTm7A)
10
11Pros:
12* Technology independent GUI development, rendering engine may be replaced (iOS, Android, Web)
13* Extremely rapid application prototyping and development
14* GUI-based requirements engineering
15* Focus on business logic programming and GUI prototyping, not GUI programming
16
17## Live Example
18Live example on Heroku Free (please wait for wakeup): https://path-example.herokuapp.com/<br/>
19Source code: https://github.com/innovad/path-example
20
21## QuickStart
22
23Run a Path example application with 4 steps:
24* Clone the Path example from https://github.com/innovad/path-example
25* Open console in project folder, run <code>npm install</code> (requires npm: https://www.npmjs.com/)
26* Run <code>npm run start-dev</code> and open web application in browser: <code>http://localhost:8080</code>
27* Play around with the sample GUI model in <code>app/gui-model/guimodel.ts</code> and reload browser window to view changes, e.g. use the following HelloWorld model which displays a single HelloWorld button showing <code>HelloWorldForm</code>.
28
29```json
30{
31 "application": {
32 "title": "Path Demo",
33 "formList": [
34 {
35 "id": "HelloWorldForm",
36 "title": "HelloWorld",
37 "formFieldList": [
38 {
39 "id": "name",
40 "type": "text",
41 "name": "Project",
42 "width": 2,
43 "required": true
44 },
45 {
46 "type": "deleteButton",
47 "name": "Delete"
48 },
49 {
50 "type": "cancelButton",
51 "name": "Cancel"
52 },
53 {
54 "type": "okButton",
55 "name": "Ok"
56 }
57 ]
58 },
59 ],
60 "pageList": [
61 {
62 "id": "mainmenu",
63 "name": "MainMenu",
64 "elementList": [
65 {
66 "type": "button",
67 "name": "HelloWorld",
68 "icon": "fa-fast-forward",
69 "color": "alizarin",
70 "form": {
71 "form": "HelloWorldForm"
72 }
73 }
74 ]
75 }
76 ]
77 }
78}
79```
80
81## GUI Model
82
83A Path application consists of a [page](#pages) and [form](#forms) list:
84
85```json
86{
87 "application": {
88 "title": "Path Example",
89 "formList": [],
90 "pageList": []
91 }
92}
93```
94
95### Pages<a name="pages"></a>
96
97A page consists of a list of page elements. Page elements may be either page buttons or lists.
98
99```json
100{
101 "id": "mainmenu",
102 "name": "MainMenu",
103 "elementList": [
104 ]
105}
106```
107
108#### Page Elements
109
110Path displays one or more page elements on a single web page. Each element has several properties.
111
112| Property | Description |
113| ------------- | ------------- |
114| id | The page element id |
115| type | The page element type (e.g. button, list, ...) |
116| newRow | Force the layout manager to place the page element on a new row (false by default) |
117
118##### Buttons and Tiles
119
120Buttons may either open another page, open a form or open an url. A tile cannot be clicked.
121This example links to another page (type <b>button</b>):
122
123```json
124{
125 "type": "button",
126 "name": "Contacts",
127 "icon": "fa-user",
128 "color": "blue",
129 "page": "contactspage"
130}
131```
132
133Another example opens a path form (type <b>button</b>):
134
135```json
136{
137 "type": "button",
138 "name": "Contacts",
139 "form": {
140 "form": "ContactForm"
141 }
142}
143```
144
145And this example opens an external link (type <b>linkButton</b>):
146
147```json
148{
149 "type": "linkButton",
150 "name": "www.google.com",
151 "icon": "fa-google",
152 "url": "http://www.google.com"
153}
154```
155
156##### Lists
157
158A list is a dynamic set of buttons, either loaded from an url or from mock data.
159This example loads data from an url, and each button opens a form.
160
161| Property | Description |
162| ------------- | ------------- |
163| icon | the default icon for list buttons, may be overwritten by server data |
164| color | the default color for list buttons, may be overwritten by server data |
165| search | show (true) or hide (false) search box |
166| searchRequired | automatically load results when the list is displayed (false) or require the user to search (true, recommended for large lists) |
167| searchRequest | search filter is client side (false) or create new request with every search (true) |
168| limit | limit the number of results, parameter may be used by server service |
169
170```json
171{
172 "type": "list",
173 "name": "TaskList",
174 "icon": "fa-tasks",
175 "color": "wisteria",
176 "search": true,
177 "url": "/task",
178 "form": {
179 "form": "TaskForm"
180 }
181}
182```
183
184##### Label
185
186A label may contain text or HTML snippets. A label is always shown with full page width.
187
188```json
189{
190 "type": "pageLabel",
191 "value": "Example <b>Text</b>"
192}
193```
194
195##### Element List
196
197The URL returns a dynamic set of path elements in JSON format. Use this element to dynamically create page elements.
198
199```json
200{
201 "type": "elementList",
202 "url": "/example/elements"
203}
204```
205
206### Forms<a name="forms"></a>
207
208Forms are usually opened from page buttons. A form contains a list of form fields.
209
210```json
211{
212 "id": "HobbyForm",
213 "title": "Hobby",
214 "url": "/hobby",
215 "formFieldList": [
216 {
217 "id": "name",
218 "type": "text",
219 "name": "HobbyName",
220 "width": 2,
221 "required": true
222 },
223 {
224 "type": "deleteButton",
225 "name": "Delete"
226 },
227 {
228 "type": "cancelButton",
229 "name": "Cancel"
230 },
231 {
232 "type": "okButton",
233 "name": "Ok"
234 }
235 ]
236}
237```
238
239#### Form fields
240
241Form field models are objects. Fields are automatically arranged on the form with the Path layout manager based on the field properties.
242
243| Property | Description |
244| ------------- | ------------- |
245| id | The field id, used as JSON key when transferring data to/from the server |
246| name | A translation key for the name of the field |
247| type | The field type (e.g. text, number, ...) |
248| width | The logical width, current 1 and 2 are supported |
249| newRow | Force the layout manager to place the field on a new row. |
250| visible | Visibility of the field |
251| labelVisible | Visibility of the field label |
252| required | Mandatory field if true. |
253| readonly | Disabled field if true. |
254
255The followings form fields can be used on a form:
256
257##### Auto Complete
258
259Autocomplete fields show a suggestion list when typing or pressing space key.
260
261```json
262{
263 "id": "company",
264 "type": "autocomplete",
265 "name": "Company",
266 "wordSearchEnabled": true,
267 "defaultKey": "companyKey",
268 "form": "CompanyForm",
269 "url": "/company",
270 "width": 2
271}
272```
273
274##### Button
275
276Ok, Cancel and Delete buttons are supported.
277
278##### Checkbox
279
280One or more checkboxes.
281
282##### Date
283
284Date fields show a date chooser.
285
286```json
287{
288 "id": "evtBirth",
289 "type": "date",
290 "name": "Birthday",
291 "width": 2
292}
293```
294
295##### Fieldlist
296
297With Fieldlists you can create fields dynamically. The url should response with a list of field models. Any field (except Fieldlist itself) may be created dynamically.
298
299```json
300{
301 "type": "fieldList",
302 "name": "Category",
303 "width": 2,
304 "url": "/category"
305}
306```
307
308##### Label
309
310Label fields.
311
312##### Number
313
314Support for numeric data. Minimum, maximum and digits can be configured.
315
316```json
317{
318 "id": "level",
319 "type": "number",
320 "name": "Level",
321 "width": 2,
322 "min": 1,
323 "max": 99999,
324 "digits": 0,
325 "required": true
326}
327```
328
329##### Progress Bar
330
331The value of the field is shown as progress.
332
333##### Radio
334
335One or more radio buttons.
336
337##### Text
338
339Single or multi-line text input fields.
340
341```json
342{
343 "id": "comment",
344 "type": "text",
345 "name": "Comments",
346 "width": 2,
347 "height": 4,
348 "maxLength": 5000,
349}
350```
351
352##### Translation
353
354Like text fields, but with built-in support for translated text.
355
356## Path Framework Development
357
358![Path Architecture](https://github.com/innovad/path/blob/master/path-architecture.png)
359
360Read this chapter if you want to contribute to the Path Framework. If you only want to create applications using Path Framework, the following steps are *not* necessary.
361
362* Create a directory where you will put your development code
363* Clone the framework and the example application in two separate folders inside this directory:
364```
365git clone https://github.com/innovad/path.git
366git clone https://github.com/innovad/path-example.git
367```
368* Run npm install on both projects (path and path-example)
369* Unfortunately we cannot use npm link to create a local dependency from path-example to path since it is not supported by TypeScript/Angular. We use npm-link-copy to make path-example use our local path project:
370```
371npm install -g laggingreflex/npm-link-copy
372```
373* Execute the following command in the path (framework) directory:
374```
375npm link
376```
377* Now we can use path-framework in the path-example project. Using the -w option, it will watch for changes on the path-framework and update automatically. Execute the following command in the path-example directory:
378```
379npm-link-copy path-framework -w
380```
381* Finally you can test your development cycle. First, change some code in the framework. Run 'npm run tsc' to compile it to TypeScript (may be done by your IDE). Now the browser (showing path-example) should automatically reload and show your changes.