1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
<?xml version="1.0" encoding="ISO-8859-1"?> |
2 |
|
<form title="Países" tabbed="top" width="80" height="25"> |
3 |
|
|
4 |
<form tabbed="top" title="ABM de Países"> |
<datasource name="focusDataSource" cache="1"></datasource> |
5 |
<neb:Block> |
<datasource name="searchDataSource" cache="1"></datasource> |
6 |
my $database = 'papo'; |
<!-- This component is originally based on neb/examples/db.neb, --> |
7 |
my $table = 'country'; |
<!-- although it might diverge in the future. The idea that this is --> |
8 |
my $order_by = 'name'; |
<!-- the working version, whereas that is a simple example. So any --> |
9 |
|
<!-- hacks go here; keep the example clean, if less "magic". --> |
10 |
my $search = [ |
|
11 |
{ 'field' => 'name', |
<datasource name="resultDataSource" database="papo" order_by="_country_data.name" table="_country_data"> |
12 |
'search_label' => 'Nombre del país a buscar', |
<condition> |
13 |
'result_label' => 'Nombre', |
<and><!-- Only current country's, please --> |
14 |
}, |
<null> |
15 |
{ 'field' => 'iso2', |
<cfield name="_country_data._end_t"></cfield> |
16 |
'search_label' => 'Código ISO 3166-1 Alpha-2', |
</null> |
17 |
'result_label' => 'iso2', |
</and> |
18 |
}, |
</condition> |
19 |
]; |
</datasource> |
20 |
my $fields = [ |
<!-- This component is originally based on neb/examples/db.neb, --> |
21 |
{ 'field' => 'name', |
<!-- although it might diverge in the future. The idea that this is --> |
22 |
'desc' => 'Nombre ISO 3166-1 (Inglés)', |
<!-- the working version, whereas that is a simple example. So any --> |
23 |
}, |
<!-- hacks go here; keep the example clean, if less "magic". --> |
24 |
{ 'field' => 'iso2', |
|
25 |
'desc' => 'Código ISO 3166-1 Alpha-2', |
<datasource name="editDataSource" database="papo" table="country,_country_data" historytable="_country_data" |
26 |
}, |
order_by="_country_data.name"> |
27 |
{ 'field' => 'iso3', |
<condition> |
28 |
'desc' => 'Código ISO 3166-1 Alpha-3', |
<and><!-- pega country con su _table --> |
29 |
}, |
<eq> |
30 |
{ 'field' => 'phone', |
<cfield name="country.id"></cfield> |
31 |
'desc' => 'Código ITU E.164', |
<cfield name="_country_data._table"></cfield> |
32 |
}, |
</eq><!-- Only current country's, please --> |
33 |
{ 'field' => 'un', |
<null> |
34 |
'desc' => 'Código ONU', |
<cfield name="_country_data._end_t"></cfield> |
35 |
}, |
</null> |
36 |
]; |
</and> |
37 |
my $pages = { 'search' => 'Países', |
</condition> |
38 |
'edit' => 'Datos del País', |
</datasource> |
39 |
}; |
<trigger name="searchTrigger" type="NAMED"> |
40 |
|
try: |
41 |
|
from gnue.forms.GFEvent import GFEvent |
42 |
</neb:Block> |
except ImportError: |
43 |
<neb:Sub neb:src="generic.nebc" search="neb:$search" |
from gnue.common.events.Event import Event as GFEvent |
44 |
fields="neb:$fields" pages="neb:$pages" database="neb:$database" |
|
45 |
table="neb:$table" order_by="neb:$order_by"/> |
setStatusText('buscando...') |
46 |
|
|
47 |
|
self._object.dispatchEvent(GFEvent('beginWAIT')) |
48 |
|
|
49 |
|
resultBlock.clear() |
50 |
|
resultBlock.initQuery() |
51 |
|
resultBlock.listEntry0 = str(searchBlock.searchEntry0)+'%' |
52 |
|
resultBlock.listEntry1 = str(searchBlock.searchEntry1)+'%' |
53 |
|
resultBlock.processQuery() |
54 |
|
|
55 |
|
setStatusText('Aceptar') |
56 |
|
self._object.dispatchEvent(GFEvent('endWAIT')) |
57 |
|
|
58 |
|
if resultBlock.isEmpty(): |
59 |
|
searchBlock.notificationEntry = ' no se encontraron registros' |
60 |
|
else: |
61 |
|
searchBlock.notificationEntry ='%6d registros encontrados' % resultBlock.getRecordCount() |
62 |
|
</trigger> |
63 |
|
<trigger name="commitTrigger" type="NAMED"> |
64 |
|
from gnue.common.GDataObjects import ConnectionError as DBError |
65 |
|
|
66 |
|
try: |
67 |
|
editBlock.postChanges() |
68 |
|
commitConnection() |
69 |
|
except DBError, err: |
70 |
|
rollbackConnection() |
71 |
|
genericBox("Hay problemas para grabar los datos\n"+str(err),['Aceptar']) |
72 |
|
|
73 |
|
</trigger> |
74 |
|
<trigger name="deleteTrigger" type="NAMED"> |
75 |
|
from gnue.common.GDataObjects import ConnectionError as DBError |
76 |
|
|
77 |
|
try: |
78 |
|
editBlock.deleteRecord() |
79 |
|
editBlock.postChanges() |
80 |
|
commitConnection() |
81 |
|
except DBError, err: |
82 |
|
rollbackConnection() |
83 |
|
genericBox("Hay problemas para borrar los datos \n"+str(err),['Aceptar']) |
84 |
|
</trigger> |
85 |
|
<trigger name="rollbackTrigger" type="NAMED"> |
86 |
|
editBlock.reset() |
87 |
|
</trigger> |
88 |
|
<trigger name="askForChangesTrigger" type="NAMED"> |
89 |
|
import hack |
90 |
|
hack.confirmPageChanges(self, 'commitTrigger', editBlock) |
91 |
|
</trigger> |
92 |
|
<trigger name="newTrigger" type="NAMED"> |
93 |
|
import hack |
94 |
|
hack.confirmRollback (self, editBlock, 'commitTrigger') |
95 |
|
</trigger> |
96 |
|
<page name="Países"> |
97 |
|
|
98 |
|
<trigger type="Pre-Focusout"> |
99 |
|
editBlock.clear() |
100 |
|
if resultBlock.getRecordCount() > 0 and not resultBlock.getCurrentRecord().isEmpty(): |
101 |
|
editBlock.initQuery() |
102 |
|
editBlock.idEntry = ("%s" % resultBlock.idREntry) |
103 |
|
editBlock.processQuery() |
104 |
|
|
105 |
|
</trigger> |
106 |
|
<block name="searchBlock" transparentBlock="" datasource="searchDataSource" restrictInsert=""> |
107 |
|
|
108 |
|
<label text="Nombre del país a buscar" x="2" y="1" width="25"></label> |
109 |
|
<entry name="searchEntry0" x="2" y="2" width="76" height="1"></entry> |
110 |
|
<label text="Código ISO 3166-1 Alpha-2" x="2" y="3" width="26"></label> |
111 |
|
<entry name="searchEntry1" x="2" y="4" width="76" height="1"></entry> |
112 |
|
<button name="searchBtn" trigger="searchTrigger" label="Buscar" x="2" y="5" width="10" height="1"></button> |
113 |
|
<entry style="label" name="notificationEntry" x="1" y="24" width="67"/> |
114 |
|
</block> |
115 |
|
|
116 |
|
<block name="resultBlock" transparentBlock="y" datasource="resultDataSource" restrictInsert="y"> |
117 |
|
<entry name="idREntry" hidden="y" field="_table" x="2" y="7"></entry> |
118 |
|
|
119 |
|
<label text="Nombre" x="2" y="7" width="6"></label> |
120 |
|
<entry name="listEntry0" max_length="80" rows="16" field="_country_data.name" x="2" y="8" width="36" height="1"></entry> |
121 |
|
|
122 |
|
<label text="iso2" x="38" y="7" width="4"></label> |
123 |
|
<entry name="listEntry1" max_length="2" rows="16" field="_country_data.iso2" x="38" y="8" width="3" height="1"></entry> |
124 |
|
|
125 |
|
<label text="" x="76" y="7" width="0"></label> |
126 |
|
<scrollbar page="16" x="76" y="8" width="1" height="16"></scrollbar> |
127 |
|
</block> |
128 |
|
|
129 |
|
</page> |
130 |
|
<page name="Datos del País"> |
131 |
|
<trigger src="askForChangesTrigger" type="pre-Focusout"></trigger> |
132 |
|
<block name="editBlock" restrictInsert="y" datasource="editDataSource"> |
133 |
|
<entry name="idEntry" hidden="y" field="country.id" x="0" y="0"></entry> |
134 |
|
|
135 |
|
<button name="newButton" label="Nuevo" trigger="newTrigger" x="68" y="1" width="10" height="1"></button> |
136 |
|
<label text="Nombre ISO 3166-1 (Inglés)" x="1" y="2" width="27"></label> |
137 |
|
<entry name="nameField" max_length="80" field="_country_data.name" x="1" y="3" width="77" height="1"></entry> |
138 |
|
<label text="Código ISO 3166-1 Alpha-2" x="1" y="4" width="26"></label> |
139 |
|
<entry name="iso2Field" max_length="2" field="_country_data.iso2" x="1" y="5" width="3" height="1"></entry> |
140 |
|
<label text="Código ISO 3166-1 Alpha-3" x="1" y="6" width="26"></label> |
141 |
|
<entry name="iso3Field" max_length="3" field="_country_data.iso3" x="1" y="7" width="4" height="1"></entry> |
142 |
|
<label text="Código ITU E.164" x="1" y="8" width="17"></label> |
143 |
|
<entry name="phoneField" field="_country_data.phone" typecast="number" x="1" y="9" width="77" height="1"></entry> |
144 |
|
<label text="Código ONU" x="1" y="10" width="11"></label> |
145 |
|
<entry name="unField" field="_country_data.un" typecast="number" x="1" y="11" width="77" height="1"></entry> |
146 |
|
|
147 |
|
<button name="commitBtn" label="Aceptar" trigger="commitTrigger" x="12" y="16" width="10" height="1"></button> |
148 |
|
<button name="rollbackBtn" label="Cancelar" trigger="rollbackTrigger" x="33" y="16" width="10" height="1"></button> |
149 |
|
<button name="deleteBtn" label="Borrar" trigger="deleteTrigger" x="54" y="16" width="10" height="1"></button> |
150 |
|
|
151 |
|
</block> |
152 |
|
</page> |
153 |
</form> |
</form> |