Columns show/hide first look
authorVásáry Dániel <vasary@elgekko.net>
Sun, 25 Feb 2024 22:22:36 +0000 (23:22 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Sun, 25 Feb 2024 22:22:36 +0000 (23:22 +0100)
lis-ui/src/main/java/hu/user/lis/ui/data/common/CachedSpringDataModel.java
lis-ui/src/main/resources/web/partners.zul

index 5d8ad8bccd7069c98d75d8a64d3bb6da1fc6e258..9c278423f4c32be38914146871668767ec4bd139 100644 (file)
@@ -41,6 +41,13 @@ public abstract class CachedSpringDataModel<T> extends CachedDataModel<T> {
         } else {
             JSONObject savedColumns = entityDataService.fromJSON(profile.getSetting(), JSONObject.class);
             if (savedColumns.keySet().equals(columns.keySet())) {
+//                log.info("{}", Strings.join(objects, ','));
+                columnSettings.keySet().forEach(colName -> {
+                    LinkedHashMap<String, Object> colSetting = (LinkedHashMap<String, Object>) savedColumns.get(colName);
+                    if (!colSetting.containsKey("visible")) {
+                        colSetting.put("visible", true);
+                    }
+                });
                 columnSettings = savedColumns;
             } else {
                 saveProfileSetting();
@@ -60,6 +67,7 @@ public abstract class CachedSpringDataModel<T> extends CachedDataModel<T> {
     private void addColumn(String name, String direction) {
         JSONObject sort = new JSONObject();
         sort.put("sortDirection", direction);
+        sort.put("visible", true);
         columnSettings.put(name, sort);
 
         if (!direction.equals(NATURAL)) {
index 33562f91838576b90d061164b46b158fe87823ad..57dd7d6a57d0bcf5c4d835174c114892a9b2fb76 100644 (file)
                     <toolbarbutton mode="toggle" iconSclass="z-icon-adjust" label="Mind"
                                    checked="@bind(vm.filterShowBoth)"/>
                 </toolbar>
+
             </north>
             <center border="none" flex="true">
-                <listbox vflex="true" model="@load(vm.partnersDataModel)"
-                         autopaging="true" mold="paging" pagingPosition="top" multiple="false"
-                         onSelect="@command('onListSelection')">
-                    <listhead sizable="true">
-                        <listheader label="Név" sort="auto(name)" align="left"
-                                    sortDirection="@load(vm.cols['name'].sortDirection)"/>
-                        <listheader label="Adószám" sort="auto(vatNr)" align="left"
-                                    sortDirection="@load(vm.cols['vatNr'].sortDirection)"/>
-                        <listheader label="Cím" sort="auto(address)" align="left"
-                                    sortDirection="@load(vm.cols['address'].sortDirection)"/>
-                        <listheader label="Aktív" sort="auto(active)" align="left"
-                                    sortDirection="@load(vm.cols['active'].sortDirection)"/>
+                <vlayout>
+                    <!--                    https://www.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM/Data_Binding/Children_Binding-->
+                    <menupopup id="editPopup">
+                        <menuitem label="Group" image="~./zul/img/grid/menu-group.png"/>
+                        <menuitem label="Sort Ascending" image="~./zul/img/grid/menu-arrowup.png"/>
+                        <menuitem label="Sort Descending" image="~./zul/img/grid/menu-arrowdown.png"/>
+                    </menupopup>
+                    <listbox vflex="true" model="@load(vm.partnersDataModel)"
+                             autopaging="true" mold="paging" pagingPosition="top" multiple="false"
+                             onSelect="@command('onListSelection')">
+                        <listhead sizable="true" menupopup="editPopup">
+                            <listheader label="Név" sort="auto(name)" align="left"
+                                        visible="@bind(vm.cols['name'].visible)"
+                                        sortDirection="@load(vm.cols['name'].sortDirection)"/>
+                            <listheader label="Adószám" sort="auto(vatNr)" align="left"
+                                        sortDirection="@load(vm.cols['vatNr'].sortDirection)"/>
+                            <listheader label="Cím" sort="auto(address)" align="left"
+                                        sortDirection="@load(vm.cols['address'].sortDirection)"/>
+                            <listheader label="Aktív" sort="auto(active)" align="left"
+                                        sortDirection="@load(vm.cols['active'].sortDirection)"/>
+
+                        </listhead>
+                        <template name="model">
+                            <listitem onDoubleClick="@command('onEdit')">
+                                <listcell label="@load(each.name)"/>
+                                <listcell label="@load(each.vatNr)"/>
+                                <listcell label="@load(each.address)"/>
+                                <listcell>
+                                    <a iconSclass="z-icon-check" visible="@load(each.active)"/>
+                                    <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
+                                </listcell>
+                            </listitem>
+                        </template>
+                    </listbox>
 
-                    </listhead>
-                    <template name="model">
-                        <listitem onDoubleClick="@command('onEdit')">
-                            <listcell label="@load(each.name)"/>
-                            <listcell label="@load(each.vatNr)"/>
-                            <listcell label="@load(each.address)"/>
-                            <listcell>
-                                <a iconSclass="z-icon-check" visible="@load(each.active)"/>
-                                <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
-                            </listcell>
-                        </listitem>
-                    </template>
-                </listbox>
+                </vlayout>
             </center>
         </borderlayout>
     </window>