Separate ValidatePlant and CheckSyntax
[L-seed.git] / web / php / page / createplant.pg
1 {
2         id: 'ContentPanel_createplant'
3         ,closable: true
4         ,style: 'padding: 5px;'
5         ,title: 'Neue Pflanze erstellen'
6         ,layout: 'form'
7         ,labelWidth: 100
8         ,baseCls: 'x-plain'
9         ,bodyStyle:'padding:5px;'
10         ,defaults: {
11                 bodyStyle:'padding:5px;'
12         }
13         ,tbar: [{
14                 text: "Save"
15                 ,icon: 'img/icons/disk.png'
16                 ,cls: 'x-btn-text-icon'
17                 ,handler: function() {
18                         var namefield = Ext.getCmp("plantdefinitionnamefield");
19                         var planteditor = Ext.getCmp("plantdefinitioneditor");
20                         if (namefield.isValid()) {
21                         
22                                 var plant = new Lseed.Plant({
23                                         Name: namefield.getValue() 
24                                         ,Code: planteditor.getValue()
25                                 });
26                                 editor.Save(plant);
27                                 editor.Edit(plant);
28                                 communication.closeTab("createplant");
29                         } else {
30                                 communication.showMessage("Ihre Pflanze benötigt einen Namen.", "error");
31                         }
32                 }
33         },{
34                 text: "CheckSyntax"
35                 ,icon: 'img/icons/accept.png'
36                 ,cls: 'x-btn-text-icon'
37                 ,handler: function() { 
38                         communication.waitForPage();
39                         var pdEditor = Ext.getCmp("plantdefinitioneditor");
40                         var pnEditor = Ext.getCmp("plantdefinitionnamefield");
41                         if (pdEditor && pnEditor) {
42                                 var name = pnEditor.getValue();
43                                 var code = pdEditor.getValue();
44                                 editor.CheckSyntax({data:{Code:code, Name:name}});
45                         } else {
46                                 console.error("Lseed.Editor.CheckSyntaxCallback_Callback: 'plantdefinitioneditor' Could not be found.");
47                         }
48                 }.createDelegate(editor)
49         }]
50         ,items: [{
51                 id: "plantdefinitionnamefield"
52                 ,xtype: 'textfield'
53                 ,name: 'name'
54                 ,allowBlank: false
55                 ,fieldLabel: 'Name der Pflanze'
56                 ,anchor:'100%'
57                 ,enableKeyEvents: true
58                 ,listeners: {
59                 }
60         },{
61                 id: "plantdefinitioneditor"
62                 ,xtype: 'textarea'
63                 ,name: 'code'
64                 ,fieldLabel: 'Pflanzendefinition'
65                 ,anchor:'100% -50'
66                 ,enableKeyEvents: true
67                 ,listeners: {
68                 }
69                 ,value: 'RULE "MyRule"\nGROW BY 1'
70         }]
71 }