Skip to content

Commit 82a7f82

Browse files
committed
Refactor code to minimize mixing content/presentation
1 parent f65cea3 commit 82a7f82

File tree

2 files changed

+28
-67
lines changed

2 files changed

+28
-67
lines changed

CodeTree/Innovator/Client/customer/myStyles.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ input[type="image"] {
157157
display: block;
158158
margin-left: 15px;
159159
margin-bottom: 30px;
160+
font-size: 16px;
161+
font-weight: bold;
160162
}
161163

162164
/* Custom CSS by ID */

Import/CustomFormCss/Import/Fixes/Part.xml

Lines changed: 26 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -267,73 +267,52 @@ function createNewRevision()
267267
<font_size>8pt</font_size>
268268
<font_weight>bold</font_weight>
269269
<html_code>
270-
<![CDATA[<img id="myIcon" name="myIcon" src="../customer/svg/calendar.svg" vspace="20" hspace="20" />
270+
<![CDATA[<img id="myIcon" name="myIcon" src="../customer/svg/package.svg" vspace="20" hspace="20" />
271271
272272
<script>
273-
274273
chooseIcon = function()
275274
{
275+
var icn = "../customer/svg/";
276+
277+
// get classification, gets "none" if getProperty returns null
276278
var thisItem = document.thisItem;
277279
var classification = thisItem.getProperty("classification","none");
278280
279-
//alert("classification = " + classification);
280-
281+
// get icon fields
281282
var defIcon = document.getElementById("large_icon_img");
282-
283283
var myIcon = document.getElementById("myIcon");
284-
var icn = "../customer/svg/";
285284
285+
// choose file name
286286
switch (classification)
287287
{
288288
case "none":
289-
// show default part icon
289+
// choose part icon file
290290
icn = defIcon.getAttribute("src");
291-
myIcon.style.visibility = "visible";
292-
myIcon.style.display = "block";
293-
defIcon.style.visibility = "hidden";
294-
295291
break;
296-
297292
case "Assembly":
298-
myIcon.style.visibility = "visible";
299-
myIcon.style.display = "block";
300-
defIcon.style.visibility = "hidden";
301-
302293
icn += "package.svg";
303294
break;
304-
305295
case "Component":
306-
myIcon.style.visibility = "visible";
307-
myIcon.style.display = "block";
308-
defIcon.style.visibility = "hidden";
309-
310296
icn += "circuit-board.svg";
311297
break;
312-
313298
case "Material":
314-
myIcon.style.visibility = "visible";
315-
myIcon.style.display = "block";
316-
defIcon.style.visibility = "hidden";
317-
318299
icn += "beaker.svg";
319300
break;
320-
321301
case "Software":
322-
myIcon.style.visibility = "visible";
323-
myIcon.style.display = "block";
324-
defIcon.style.visibility = "hidden";
325-
326302
icn += "file-binary.svg";
327303
break;
328304
}
329305
306+
// style custom icon
330307
myIcon.setAttribute("src",icn);
331-
}
332-
333-
308+
myIcon.style.visibility = "visible";
309+
myIcon.style.display = "block";
334310
311+
// hide default icon element
312+
defIcon.style.visibility = "hidden";
313+
}
314+
// choose icon onLoad
335315
window.addEventListener("load", chooseIcon);
336-
337316
</script>
338317
339318
]]>
@@ -359,69 +338,49 @@ function createNewRevision()
359338
<font_size>8pt</font_size>
360339
<font_weight>bold</font_weight>
361340
<html_code>
362-
<![CDATA[<span id="ITEM_INFO_INTERNAL_SPAN" class="info_group" style="display:block;">
341+
<![CDATA[<span id="ITEM_INFO_INTERNAL_SPAN" class="info_group" style="display:block;"></span>
363342
364-
</span>
365343
<script>
366344
populate_ITEM_INFO_INTERNAL_SPAN = function()
367345
{
368346
document.getElementById("ITEM_INFO_INTERNAL_SPAN").innerHTML = top.aras.uiDrawItemInfoTable(document.itemType);
369347
top.aras.uiPopulateInfoTableWithItem(document.item, document);
370-
348+
// apply customizations in separate function
371349
style_ITEM_INFO_INTERNAL_SPAN();
372350
}
373-
374351
style_ITEM_INFO_INTERNAL_SPAN = function()
375352
{
353+
// override default icon style
376354
var lg_icn = document.getElementById("large_icon_img");
377355
lg_icn.style = '';
378-
356+
var tbl = document.getElementById("itemInfoTable");
357+
tbl.style.marginTop = "45px";
358+
// add element to display styled state
379359
var container = document.getElementById("ITEM_INFO_INTERNAL_SPAN");
380360
var stateLabel = document.createElement("span");
381361
stateLabel.className = "my_state";
382362
container.appendChild(stateLabel);
383-
384-
var oldIcon = document.getElementById("large_icon_img");
385-
//oldIcon.style.visibility = "hidden";
386-
387-
var tbl = document.getElementById("itemInfoTable");
388-
tbl.style.marginTop = "45px";
389-
363+
// set value of new state element
390364
var stateValue = document.getElementById("itemProps$state");
391365
stateValue = stateValue.textContent;
392-
var stateRow = document.getElementById("state_row");
393-
394366
stateLabel.innerHTML = stateValue.toUpperCase();
395-
stateLabel.style.fontSize = "16px";
396-
stateLabel.style.fontWeight = "bold";
397-
367+
// style new state element color based on LC state
398368
if (stateValue == "Released")
399-
{
400369
stateLabel.style.color = "red";
401-
}
402-
403370
if (stateValue == "Preliminary")
404-
{
405371
stateLabel.style.color = "green";
406-
}
407-
408-
if (!stateValue)
409-
{
410-
// stateLabel.style.visibility = "hidden";
411-
// stateLabel.style.display = "none";
412-
}
413-
372+
// hide default state property in table
373+
var stateRow = document.getElementById("state_row");
414374
stateRow.style.visibility = "hidden";
415375
stateRow.style.display = "none";
416-
376+
// display classification as title
417377
var thisItem = document.thisItem;
418378
var classification = thisItem.getProperty("classification","Part");
419379
var titleEl = document.getElementById("label_span");
420380
titleEl.innerHTML = classification;
421381
}
422-
382+
// populate item_info table onLoad
423383
window.addEventListener("load", populate_ITEM_INFO_INTERNAL_SPAN);
424-
425384
</script>
426385
]]>
427386
</html_code>

0 commit comments

Comments
 (0)