change the initialization of shortcuts initialData.md

parent b7456e6a
......@@ -4,7 +4,7 @@
[Creating a folder for a submenu](#menu_folder)
[Adding a shortcut](#shortcut)
[Filling the data fields from datasets](#dir)
[Using Enum enum in models](#enum)
[Using Enum in models](#enum)
[Localization of the project](#localize)
......@@ -59,37 +59,50 @@ module.exports = function (session) {
```
Save the file and run the command
`ubcli initialize -u admin -p admin -host http://localhost:888 -m RequestList`
Where RequestList is a model name specified in ubConfig.json
After that (re) start the UB server and go to the admin panel.
Ensure that the desktop is created in the admin panel.
![desktop_view](img/initialData/desktop_view.png)
<a name = 'menu_folder'></a>
## Create a folder for a submenu
Create a folder Departments on your desktop City Requests.
To do this in `010_create_navshortcuts.js` file between the lines
```javascript
desktopID = conn.insert({
//...
}
});
Add the following code to the module.exports () function in `010_create_navshortcuts.js` file
```
and
```javascript
}
else { //else display a message
console.info('\t\tuse existed desktop with code `CityReq_desktop`', desktopID);
}
```
add the following code
console.log('\t\tcreate `Departments` folder');
folderID = conn.insert({
entity: 'ubm_navshortcut',
fieldList: ['ID'],
execParams: {
desktopID: desktopID,
code: 'req_departments_folder',
caption: 'Departments',
isFolder: true,
isCollapsed:false,
displayOrder: 10
}
});
```javascript
folderID = conn.lookup('ubm_navshortcut', 'ID', {expression: 'code', condition: 'equal', values: {code: 'req_departments_folder'}});
if (!folderID) {
console.log('\t\tcreate `Departments` folder');
folderID = conn.insert({
entity: 'ubm_navshortcut',
fieldList: ['ID'],
execParams: {
desktopID: desktopID,
code: 'req_departments_folder',
caption: 'Departments',
isFolder: true,
isCollapsed:false,
displayOrder: 10
}
});
}
else {
console.info('\t\tuse existed folder with code `req_departments_folder`', folderID);
}
```
<a name = 'shortcut'></a>
......@@ -97,29 +110,67 @@ console.log('\t\tcreate `Departments` folder');
## Adding a shortcut.
To the folder Departments add the shortcut Departments
To the folder Departments add the shortcut Departments
To do this in `010_create_navshortcuts.js` file between the lines
```javascript
folderID = conn.insert({
//...
}
});
```
and
```javascript
}
else { //else display a message
console.info('\t\tuse existed folder with code `req_departments_folder`', folderID);
}
```
add the following code
console.log('\t\t\tcreate `Department` shortcut');
lastID = conn.insert({
fieldList: ['ID'],
entity: 'ubm_navshortcut',
execParams: {
desktopID: desktopID,
parentID: folderID,
code: 'req_depart',
caption: 'Departments',
iconCls: 'fa fa-building-o',
displayOrder: 10,
cmdCode : JSON.stringify({cmdType: 'showList', cmdData: {params:[{ entity: 'req_depart', method: 'select', fieldList: '*'}]}}, null, '\t')
}
});
```javascript
lastID = conn.lookup('ubm_navshortcut', 'ID', {expression: 'code', condition: 'equal', values: {code: 'req_depart'}});
if(!lastID) {
console.log('\t\t\tcreate `Department` shortcut');
lastID = conn.insert({
fieldList: ['ID'],
entity: 'ubm_navshortcut',
execParams: {
desktopID: desktopID,
parentID: folderID,
code: 'req_depart',
caption: 'Departments',
iconCls: 'fa fa-building-o',
displayOrder: 10,
cmdCode : JSON.stringify({cmdType: 'showList', cmdData: {params:[{ entity: 'req_depart', method: 'select', fieldList: '*'}]}}, null, '\t')
}
});
}
else {
console.info('\t\tuse existed shortcut with code `req_depart`', lastID);
}
```
Independently create shortcuts for the SubDepartments menu and Request List, execute the command `ubcli initialize` and make sure that the script is executed correctly.
Independently create the `SubDepartments` menu in the Departments folder and the `Request List` shortcut.
The full code listing of `010_create_navshortcuts.js` file is find here
https://git-pub.intecracy.com/unitybase/samples/blob/master/courses/cityPortal-v4/models/requests/_initialData/010_create_navshortcuts.js
To run the script, run the command in the root of project
`ubcli initialize -u admin -p admin -host http://localhost:888 -m RequestList'
The following message should appear in the console:
![creating_shortcut_console](img/initialData/creating_shortcut_console.PNG)
If you see the following message
![desktop_exist_error](img/initialData/desktop_exist_error.png)
This means that the desktop was created earlier. You can
* delete the created menu items manually in the admin panel
* execute the file `init.cmd` that will reinitialize the entire project.In this case, all the shortcuts, roles and users previously created in the admin panel are deleted. Forms, reports and charts remain in the folder as files.
<a name = 'dir'></a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment