Bladeren bron

Prototype department list management

Neal Wilson 5 jaren geleden
bovenliggende
commit
6735c11109
Getekend door: Neal Wilson <neal@typica.us> GPG sleutel-ID: 2A0BDDE701E66EB9
3 gewijzigde bestanden met toevoegingen van 90 en 10 verwijderingen
  1. 39
    0
      config/Windows/departmentlist.xml
  2. 13
    10
      config/Windows/navigation.xml
  3. 38
    0
      config/Windows/renamedepartment.xml

+ 39
- 0
config/Windows/departmentlist.xml Bestand weergeven

@@ -0,0 +1,39 @@
1
+<window id="departmentlist">
2
+    <layout type="vertical">
3
+        <layout type="horizontal">
4
+            <!-- Reserved for filters, &c. -->
5
+        </layout>
6
+        <sqlview id="departments" />
7
+    </layout>
8
+    <menu name="File">
9
+        <item id="newdepartment">New Department</item>
10
+    </menu>
11
+    <program>
12
+        <![CDATA[
13
+var window = this;
14
+this.windowTitle = TTR("departmentlist", "Typica - Department List");
15
+var departments = findChildObject(this, "departments");
16
+var update = function() {
17
+    departments.setQuery("SELECT id, name FROM depts ORDER BY id");
18
+};
19
+update();
20
+//var notification = Application.subscribe("deptschange");
21
+//notification.notify.connect(update);
22
+departments.openEntryRow.connect(function(row) {
23
+    var args = new Object;
24
+    args.newDepartment = false;
25
+    args.currentName = departments.data(row, 1);
26
+    args.departmentId = departments.data(row, 0);
27
+    args.updateCallback = update;
28
+    createWindow("renamedepartment", args);
29
+});
30
+var newdepartment = findChildObject(this, "newdepartment");
31
+newdepartment.triggered.connect(function() {
32
+    var args = new Object;
33
+    args.newDepartment = true;
34
+    args.updateCallback = update;
35
+    createWindow("renamedepartment", args);
36
+});
37
+        ]]>
38
+    </program>
39
+</window>

+ 13
- 10
config/Windows/navigation.xml Bestand weergeven

@@ -2,11 +2,6 @@
2 2
     <layout type="horizontal">
3 3
     <layout type="vertical">
4 4
     <layout type="grid">
5
-        <row>
6
-            <column>
7
-                <button name="Configure Roasters" id="configure" type="push" />
8
-            </column>
9
-        </row>
10 5
         <row>
11 6
             <column>
12 7
                 <button name="Roasting Schedule" id="schedule" type="push" />
@@ -81,13 +76,17 @@
81 76
     <webview id="dashboard" stretch="1" />
82 77
     </layout>
83 78
     <menu name="Reports" type="reports" src="Reports" />
84
-    <menu name="Database">
85
-        <item id="resetconnection">Forget Connection Details</item>
86
-    </menu>
87 79
 	<menu name="Users">
88 80
 		<item id="switchuser">Switch User</item>
89 81
 		<item id="createuser">Create New Users</item>
90 82
 	</menu>
83
+    <menu name="Settings">
84
+        <item id="resetconnection">Forget Database Connection</item>
85
+        <item id="configure">Preferences</item>
86
+    </menu>
87
+    <menu name="Lists">
88
+        <item id="departmentlist">Department List</item>
89
+    </menu>
91 90
     <program>
92 91
         var window = this;
93 92
         var navigationwindow = window;
@@ -182,11 +181,15 @@
182 181
                 window.loggingWindow.activateWindow();
183 182
             }
184 183
         });
185
-        var configurebutton = findChildObject(this, 'configure');
186
-        configurebutton.clicked.connect(function() {
184
+        var configure = findChildObject(this, 'configure');
185
+        configure.triggered.connect(function() {
187 186
             var confwindow = new SettingsWindow;
188 187
             confwindow.show();
189 188
         });
189
+        var departmentlist = findChildObject(this, 'departmentlist');
190
+        departmentlist.triggered.connect(function() {
191
+            createWindow("departmentlist");
192
+        });
190 193
         <![CDATA[
191 194
             var DBCreateBase = function() {
192 195
                 var query = new QSqlQuery();

+ 38
- 0
config/Windows/renamedepartment.xml Bestand weergeven

@@ -0,0 +1,38 @@
1
+<window id="renamedepartment">
2
+    <layout type="vertical">
3
+        <layout type="horizontal">
4
+            <label>Department Name:</label>
5
+            <line id="namefield" />
6
+        </layout>
7
+        <layout type="horizontal">
8
+            <button name="Save" type="push" id="save" />
9
+        </layout>
10
+    </layout>
11
+    <program>
12
+        <![CDATA[
13
+var window = this;
14
+this.windowTitle = "Typica - Set Department Name";
15
+var namefield = findChildObject(this, "namefield");
16
+if(this.arguments.newDepartment) {
17
+    namefield.text = "New Department";
18
+} else {
19
+    namefield.text = this.arguments.currentName;
20
+}
21
+var save = findChildObject(this, "save");
22
+save.clicked.connect(function() {
23
+    var query = new QSqlQuery();
24
+    if(window.arguments.newDepartment) {
25
+        query.prepare("INSERT INTO depts(id, name) VALUES (default, :name)");
26
+    } else {
27
+        query.prepare("UPDATE depts SET name = :name WHERE id = :id");
28
+        query.bind(":id", window.arguments.departmentId);
29
+    }
30
+    query.bind(":name", namefield.text);
31
+    query.exec();
32
+    query.invalidate();
33
+    window.arguments.updateCallback();
34
+    window.close();
35
+});
36
+        ]]>
37
+    </program>
38
+</window>

Laden…
Annuleren
Opslaan