Revize 7f644dea
Přidáno uživatelem Michal Linha před téměř 5 roky(ů)
src/main/java/vldc/aswi/dao/AssemblyRepository.java | ||
---|---|---|
4 | 4 |
import org.springframework.stereotype.Repository; |
5 | 5 |
import vldc.aswi.domain.Assembly; |
6 | 6 |
|
7 |
import java.util.List; |
|
8 |
|
|
7 | 9 |
/** |
8 | 10 |
* Repository for domain Assembly. |
9 | 11 |
*/ |
... | ... | |
23 | 25 |
* @return Assembly with highest order. |
24 | 26 |
*/ |
25 | 27 |
Assembly findFirst1ByOrderByAssemblyOrder(); |
28 |
|
|
29 |
/** |
|
30 |
* Find assemblies order by order |
|
31 |
* @return ordered assemblies |
|
32 |
*/ |
|
33 |
List<Assembly> getByOrderByAssemblyOrderAsc(); |
|
26 | 34 |
} |
src/main/java/vldc/aswi/service/AssemblyManager.java | ||
---|---|---|
17 | 17 |
*/ |
18 | 18 |
List<Assembly> getAssemblies(); |
19 | 19 |
|
20 |
/** |
|
21 |
* Get all Assemblies from database by order. |
|
22 |
* @return List of assemblies. |
|
23 |
*/ |
|
24 |
List<Assembly> getAssembliesOrdered(); |
|
25 |
|
|
20 | 26 |
/** |
21 | 27 |
* Get assembly by id. |
22 | 28 |
* @param id - ID of assembly. |
... | ... | |
32 | 38 |
Long updateAssembly(Assembly updatedAssemblyValues); |
33 | 39 |
|
34 | 40 |
/** |
35 |
* Update assembly's order. |
|
36 |
* @param id - ID of assembly. |
|
37 |
* @param order - Assembly's order. |
|
41 |
* Update assembly order. |
|
42 |
* @param data - sorted IDs. |
|
38 | 43 |
*/ |
39 |
void updateAssemblyOrder(Long id, int order);
|
|
44 |
void updateAssemblyOrder(String data);
|
|
40 | 45 |
|
41 | 46 |
/** |
42 | 47 |
* Create new assembly. |
src/main/java/vldc/aswi/service/AssemblyManagerImpl.java | ||
---|---|---|
68 | 68 |
return retVal; |
69 | 69 |
} |
70 | 70 |
|
71 |
/** |
|
72 |
* Get all Assemblies from database ordered. |
|
73 |
* @return List of assemblies. |
|
74 |
*/ |
|
75 |
@Override |
|
76 |
public List<Assembly> getAssembliesOrdered() { |
|
77 |
return this.assemblyRepository.getByOrderByAssemblyOrderAsc(); |
|
78 |
} |
|
79 |
|
|
71 | 80 |
/** |
72 | 81 |
* Get assembly by id. |
73 | 82 |
* @param id - ID of assembly. |
... | ... | |
81 | 90 |
} |
82 | 91 |
|
83 | 92 |
/** |
84 |
* Update assembly's order. |
|
85 |
* @param id - ID of assembly. |
|
86 |
* @param order - Assembly's order. |
|
93 |
* Update assembly order. |
|
94 |
* @param data - sorted IDs. |
|
87 | 95 |
*/ |
88 | 96 |
@Override |
89 |
public void updateAssemblyOrder(Long id, int order) { |
|
90 |
Assembly assembly = getAssemblyById(id); |
|
91 |
assembly.setAssemblyOrder(order); |
|
92 |
this.assemblyRepository.save(assembly); |
|
97 |
public void updateAssemblyOrder(String data) { |
|
98 |
String[] idOrder = data.split(","); |
|
99 |
for (int i = 0; i < idOrder.length; i++) { |
|
100 |
Assembly assembly = getAssemblyById(Long.valueOf(idOrder[i])); |
|
101 |
assembly.setAssemblyOrder(i + 1); |
|
102 |
this.assemblyRepository.save(assembly); |
|
103 |
} |
|
93 | 104 |
} |
94 | 105 |
|
95 | 106 |
/** |
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
170 | 170 |
for(int i = 0; i < newConfiguration.getParametersInConfiguration().size(); i++) { |
171 | 171 |
ParameterInConfiguration parameterInConfiguration = new ParameterInConfiguration(); |
172 | 172 |
parameterInConfiguration.setParameter(assembly.getParameters().get(i)); |
173 |
parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName()); |
|
174 | 173 |
parameterInConfiguration.setConfiguration(savedConfiguration); |
175 | 174 |
parameterInConfiguration.setOperatorValue(newConfiguration.getParametersInConfiguration().get(i).getOperatorValue()); |
176 | 175 |
parameterInConfiguration.setColumnName(assembly.getParameters().get(i).getName()); |
176 |
if(newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null && |
|
177 |
!newConfiguration.getParametersInConfiguration().get(i).getColumnName().equals("")) { |
|
178 |
parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName()); |
|
179 |
} |
|
177 | 180 |
if(newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) { |
178 |
parameterInConfiguration.setLocation(locationRepository.getByName(
|
|
179 |
newConfiguration.getParametersInConfiguration().get(i).getLocation().getName()));
|
|
181 |
parameterInConfiguration.setLocation(locationRepository.getById(
|
|
182 |
newConfiguration.getParametersInConfiguration().get(i).getLocation().getId()));
|
|
180 | 183 |
} |
181 | 184 |
if(newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) { |
182 | 185 |
parameterInConfiguration.setOperator(operatorRepository.getByName( |
... | ... | |
211 | 214 |
for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) { |
212 | 215 |
ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i); |
213 | 216 |
parameterInConfiguration.setOperatorValue(newConfiguration.getParametersInConfiguration().get(i).getOperatorValue()); |
214 |
if(newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null) { |
|
217 |
if(newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null && |
|
218 |
!newConfiguration.getParametersInConfiguration().get(i).getColumnName().equals("")) { |
|
215 | 219 |
parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName()); |
216 | 220 |
} |
217 | 221 |
if(newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) { |
218 |
parameterInConfiguration.setLocation(locationRepository.getByName( |
|
219 |
newConfiguration.getParametersInConfiguration().get(i).getLocation().getName())); |
|
222 |
parameterInConfiguration.setLocation(locationRepository.getById( |
|
223 |
newConfiguration.getParametersInConfiguration().get(i).getLocation().getId())); |
|
224 |
} |
|
225 |
else { |
|
226 |
parameterInConfiguration.setLocation(null); |
|
220 | 227 |
} |
221 | 228 |
if(newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) { |
222 | 229 |
parameterInConfiguration.setOperator(operatorRepository.getByName( |
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
106 | 106 |
Configuration configuration = new Configuration(); |
107 | 107 |
|
108 | 108 |
configuration.setAssembly(assembly); |
109 |
configuration.setTableName(assembly.getName()); |
|
109 | 110 |
configuration.setParametersInConfiguration(new ArrayList<>()); |
110 | 111 |
for(Parameter parameter : assembly.getParameters()) { |
111 | 112 |
ParameterInConfiguration parameterInConfiguration = new ParameterInConfiguration(); |
... | ... | |
117 | 118 |
} |
118 | 119 |
|
119 | 120 |
modelMap.addAttribute("configuration", configuration); |
120 |
modelMap.addAttribute("isAssembly", false); |
|
121 | 121 |
|
122 | 122 |
return modelAndView; |
123 | 123 |
} |
src/main/java/vldc/aswi/web/controller/ConfigurationController.java | ||
---|---|---|
45 | 45 |
initializeFields(configuration); |
46 | 46 |
|
47 | 47 |
modelMap.addAttribute("configuration", configuration); |
48 |
modelMap.addAttribute("isAssembly", "0"); |
|
49 | 48 |
|
50 | 49 |
return modelAndView; |
51 | 50 |
} |
src/main/java/vldc/aswi/web/controller/IndexController.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
ModelMap modelMap = modelAndView.getModelMap(); |
56 | 56 |
|
57 |
List<Assembly> assemblies = assemblyManager.getAssemblies(); |
|
57 |
List<Assembly> assemblies = assemblyManager.getAssembliesOrdered();
|
|
58 | 58 |
|
59 | 59 |
|
60 | 60 |
modelMap.addAttribute("assemblies", assemblies); |
... | ... | |
101 | 101 |
|
102 | 102 |
return attributes; |
103 | 103 |
} |
104 |
|
|
104 | 105 |
@ResponseBody |
105 | 106 |
@RequestMapping("/saveOrder") |
106 | 107 |
public String saveOrder(@RequestBody String data) { |
107 |
// seřazený idčka záznamů |
|
108 |
System.out.println(data); |
|
108 |
assemblyManager.updateAssemblyOrder(data); |
|
109 | 109 |
|
110 | 110 |
return "Ok"; |
111 | 111 |
} |
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
65 | 65 |
</td> |
66 | 66 |
<td class="select-action-buttons"> |
67 | 67 |
<optional th:each="location : ${parameterInConfiguration.parameter.locations}"> |
68 |
<span th:if="${location.name?.equals('Řádek')}" |
|
68 |
<span th:if="${location.name?.equals('Řádek')}"
|
|
69 | 69 |
th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" |
70 | 70 |
class="select-action-padding select-action-button select-input-action-margin-collapse unselectable row-button" |
71 | 71 |
th:classappend="(${configuration.parametersInConfiguration[__${itemStat.index}__].location.name?.equals('Řádek')}) ? select-action-headlight" > |
72 |
<i class="fas fa-align-justify"></i> |
|
73 |
</span> |
|
72 |
<i class="fas fa-align-justify"></i>
|
|
73 |
</span>
|
|
74 | 74 |
<span th:if="${location.name?.equals('Sloupec')}" |
75 | 75 |
th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" |
76 | 76 |
class="select-action-padding select-action-button select-input-action-margin-collapse unselectable column-button" |
77 | 77 |
th:classappend="(${configuration.parametersInConfiguration[__${itemStat.index}__].location.name?.equals('Sloupec')}) ? select-action-headlight"> |
78 |
<i class="fas fa-align-justify transform"></i> |
|
79 |
</span> |
|
78 |
<i class="fas fa-align-justify transform"></i>
|
|
79 |
</span>
|
|
80 | 80 |
<span th:if="${location.name?.equals('Hodnota')}" |
81 | 81 |
th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" |
82 | 82 |
class="select-action-padding select-action-button select-input-action-margin-collapse unselectable value-button" |
83 | 83 |
th:classappend="(${configuration.parametersInConfiguration[__${itemStat.index}__].location.name?.equals('Hodnota')}) ? select-action-headlight"> |
84 |
<i class="fas fa-heading"></i> |
|
85 |
</span> |
|
84 |
<i class="fas fa-heading"></i>
|
|
85 |
</span>
|
|
86 | 86 |
</optional> |
87 | 87 |
</td> |
88 | 88 |
<td class="s"> |
... | ... | |
124 | 124 |
</thead> |
125 | 125 |
<tbody id="row-wrapper" class="sortable"> |
126 | 126 |
<tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Řádek')}" class="row-parameter parameter"> |
127 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${i.index}__].locations}"> |
|
127 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.id}" value="1"> |
|
128 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].order}"> |
|
128 | 129 |
<td> |
129 | 130 |
<span class="parameter-name" th:text="${parameterInConfiguration.parameter.name}"></span> |
130 | 131 |
</td> |
... | ... | |
156 | 157 |
<tbody id="column-wrapper" class="sortable"> |
157 | 158 |
<tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Sloupec')}" class="column-parameter parameter"> |
158 | 159 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.id}" value="2"> |
159 |
|
|
160 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].order}"> |
|
160 | 161 |
<td> |
161 | 162 |
<span class="parameter-name" th:text="${parameterInConfiguration.parameter.name}"></span> |
162 | 163 |
</td> |
... | ... | |
186 | 187 |
</thead> |
187 | 188 |
<tbody id="value-wrapper"> |
188 | 189 |
<tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Hodnota')}" class="value-parameter parameter"> |
189 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.id}"> |
|
190 |
|
|
190 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.id}" value="3">
|
|
191 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].order}"> |
|
191 | 192 |
<td> |
192 | 193 |
<span class="parameter-name" th:text="${parameterInConfiguration.parameter.name}"></span> |
193 | 194 |
</td> |
Také k dispozici: Unified diff
re #7981 re #7979 re #7974 default table name added, assembly order implemented, parameter order in configuration implemented