@osfarm/itineraire-technique 1.1.17 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/styles-editor.css +1 -1
- package/css/styles-editor.css.map +1 -1
- package/editor.html +23 -12
- package/js/editor-attributes.js +4 -1
- package/js/editor-crops.js +3 -0
- package/js/editor-interventions.js +44 -4
- package/package.json +1 -1
- package/scss/styles-editor.scss +17 -7
package/css/styles-editor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.main-header{background-color:#6fa76f;color:#fff;height:3rem;display:flex;align-items:center}.main-header .btn.show,.main-header .btn:first-child:active,.main-header :not(.btn-check)+.btn:active{background-color:#026602}.editor-view{overflow-y:auto;height:calc(100vh - 4rem)}.rotation_item .step-edit{color:#878787;cursor:pointer;display:none;margin-left:10px;font-size:70%;vertical-align:super}.rotation_item:hover .step-edit{display:inline !important}.welcome-view{background-color:#6fa76f;color:#fff;padding:1rem;margin-top:1rem;border-radius:1rem}.welcome-view #cropsContainer{color:green}.card-white{background-color:#fff;padding:1rem;border-radius:1rem}.card-holder{background-color:#f5f5f5;padding:1rem;border-radius:1rem;margin:auto}.editable-row{background-color:#f7f7f7;min-height:3rem;display:flex;align-items:center;border-radius:.5rem}.editable-row .edit-buttons{visibility:hidden}.editable-row:hover>.edit-buttons{visibility:visible}.intervention-row{background:#e0e0e0}.primary-button{color:#fff;background-color:green;border:green}.primary-button:hover{background-color:#026602}.close-step-times{background:none;border:none;color:#878787;font-size:120%}.close-step-times:hover{color:#494949}#cropsContainer .drag-handle{color:#ccc;font-weight:normal;font-size:86%;margin-right:10px;vertical-align:middle;cursor:grab}.form-control.text-right{text-align:right}.modal .form-label{font-weight:600}#code-snippet{font-family:monospace;font-size:13px;text-align:left;border:1px inset;background-color:#f1f1f1}/*# sourceMappingURL=styles-editor.css.map */
|
|
1
|
+
.main-header{background-color:#6fa76f;color:#fff;height:3rem;display:flex;align-items:center}.main-header .btn.show,.main-header .btn:first-child:active,.main-header :not(.btn-check)+.btn:active{background-color:#026602}.editor-view{overflow-y:auto;height:calc(100vh - 4rem)}.rotation_item .step-edit{color:#878787;cursor:pointer;display:none;margin-left:10px;font-size:70%;vertical-align:super}.rotation_item:hover .step-edit{display:inline !important}.welcome-view{background-color:#6fa76f;color:#fff;padding:1rem;margin-top:1rem;border-radius:1rem}.welcome-view #cropsContainer{color:green}.card-white{background-color:#fff;padding:1rem;border-radius:1rem}.card-holder{background-color:#f5f5f5;padding:1rem;border-radius:1rem;margin:auto}.editable-row{background-color:#f7f7f7;min-height:3rem;display:flex;align-items:center;border-radius:.5rem}.editable-row .edit-buttons{visibility:hidden}.editable-row:hover>.edit-buttons{visibility:visible}.intervention-row{background:#e0e0e0}.primary-button{color:#fff;background-color:green;border:green}.primary-button:hover{background-color:#026602}.close-step-times{background:none;border:none;color:#878787;font-size:120%}.close-step-times:hover{color:#494949}#cropsContainer .drag-handle{color:#ccc;font-weight:normal;font-size:86%;margin-right:10px;vertical-align:middle;cursor:grab}#cropsContainer div.col{cursor:pointer}.form-control.text-right{text-align:right}.modal .form-label{font-weight:600}#code-snippet{font-family:monospace;font-size:13px;text-align:left;border:1px inset;background-color:#f1f1f1}#attributeName,#interventionName{font-weight:bold}/*# sourceMappingURL=styles-editor.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../scss/styles-editor.scss"],"names":[],"mappings":"AAKA,aACI,yBACA,WACA,OALiB,KAOjB,aACA,mBAEA,sGAGI,yBAIR,aACI,gBAGA,0BAKA,0BACI,cACA,eACA,aACA,iBACA,cACA,qBAGJ,gCACI,0BAIR,cACI,yBACA,WACA,aACA,gBACA,mBAEA,8BACI,YAIR,YACI,sBACA,aACA,mBAGJ,aACI,yBACA,aACA,mBACA,YAGJ,cACI,yBACA,gBAEA,aACA,mBAEA,oBAEA,4BACI,kBAGJ,kCACI,mBAIR,kBACI,mBAGJ,gBACI,MAzFiB,KA0FjB,iBA5FiB,MA6FjB,OA7FiB,MA+FjB,sBACI,iBA/Fa,QAmGrB,kBACI,gBACA,YACA,cACA,eAEA,wBACI,
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../scss/styles-editor.scss"],"names":[],"mappings":"AAKA,aACI,yBACA,WACA,OALiB,KAOjB,aACA,mBAEA,sGAGI,yBAIR,aACI,gBAGA,0BAKA,0BACI,cACA,eACA,aACA,iBACA,cACA,qBAGJ,gCACI,0BAIR,cACI,yBACA,WACA,aACA,gBACA,mBAEA,8BACI,YAIR,YACI,sBACA,aACA,mBAGJ,aACI,yBACA,aACA,mBACA,YAGJ,cACI,yBACA,gBAEA,aACA,mBAEA,oBAEA,4BACI,kBAGJ,kCACI,mBAIR,kBACI,mBAGJ,gBACI,MAzFiB,KA0FjB,iBA5FiB,MA6FjB,OA7FiB,MA+FjB,sBACI,iBA/Fa,QAmGrB,kBACI,gBACA,YACA,cACA,eAEA,wBACI,cAKJ,6BACI,WACA,mBACA,cACA,kBACA,sBACA,YAGJ,wBACI,eAKJ,yBACI,iBAKJ,mBACI,gBAIR,cACI,sBACA,eACA,gBACA,iBACA,yBAGJ,iCACI","file":"styles-editor.css"}
|
package/editor.html
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
</button>
|
|
53
53
|
<ul class="dropdown-menu">
|
|
54
54
|
<li><a class="dropdown-item" href="#" onclick="showSaveAsModal()"><i class="fa fa-save" aria-hidden="true"></i> Enregistrer sous</a></li>
|
|
55
|
-
<li><a class="dropdown-item" href="#" onclick="
|
|
55
|
+
<li><a class="dropdown-item" href="#" onclick="doExportToJsonFile()"><i class="fa fa-download" aria-hidden="true"></i> Exporter</a></li>
|
|
56
56
|
</ul>
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
<ul class="dropdown-menu">
|
|
66
66
|
<li><a class="dropdown-item" href="#" onclick="importFromTestJson()"><i class="fa fa-lightbulb-o" aria-hidden="true"></i> Charger un exemple</a></li>
|
|
67
67
|
</ul>
|
|
68
|
-
</div><button type="button" onclick="
|
|
68
|
+
</div><button type="button" onclick="doExportToJsonFile()" class="btn btn-outline-primary primary-button me-2"><i class="fa fa-download" aria-hidden="true"></i> Exporter (JSON)</button>
|
|
69
69
|
</div>
|
|
70
70
|
|
|
71
71
|
<button type="button" onclick="wipe(crops)" class="btn btn-outline-primary primary-button"><i class="fa fa-trash" aria-hidden="true"></i> Tout effacer</button>
|
|
@@ -946,27 +946,34 @@
|
|
|
946
946
|
return latestEndDate;
|
|
947
947
|
}
|
|
948
948
|
|
|
949
|
-
function addEditAndRemoveButtons(rowDiv, deleteId, editFunction, deleteFunction, duplicateFunction) {
|
|
949
|
+
function addEditAndRemoveButtons(rowDiv, deleteId, editFunction, deleteFunction, duplicateFunction, style="btn-group") {
|
|
950
950
|
rowDiv = $(rowDiv);
|
|
951
951
|
|
|
952
|
-
let actionContainer = $(
|
|
952
|
+
let actionContainer = $(`<div class="col-auto edit-buttons m-1 ${style}" role="group"></div>`);
|
|
953
953
|
|
|
954
|
-
|
|
954
|
+
rowDiv.append(actionContainer);
|
|
955
|
+
|
|
956
|
+
actionContainer.append($('<button class="edit-button btn btn-outline-primary p-2"><i class="fa fa-pencil"></i></button>').click(function(event) {
|
|
955
957
|
event.stopPropagation(); // Prevent other onclick events from triggering
|
|
956
|
-
|
|
958
|
+
editFunction();
|
|
957
959
|
}));
|
|
958
960
|
|
|
959
|
-
|
|
961
|
+
rowDiv.find('.col').click(function(event) {
|
|
960
962
|
event.stopPropagation(); // Prevent other onclick events from triggering
|
|
961
963
|
editFunction();
|
|
962
|
-
})
|
|
964
|
+
});
|
|
963
965
|
|
|
964
|
-
|
|
966
|
+
if (duplicateFunction != null) {
|
|
967
|
+
actionContainer.append($('<button class="btn btn-outline-secondary p-2"><i class="fa fa-copy"></i></button>').click(function (event) {
|
|
968
|
+
event.stopPropagation(); // Prevent other onclick events from triggering
|
|
969
|
+
duplicateFunction(deleteId);
|
|
970
|
+
}));
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
actionContainer.append($('<button class="btn btn-outline-danger p-2"><i class="fa fa-trash"></i></button>').click(function (event) {
|
|
965
974
|
event.stopPropagation(); // Prevent other onclick events from triggering
|
|
966
|
-
|
|
975
|
+
deleteFunction(deleteId);
|
|
967
976
|
}));
|
|
968
|
-
|
|
969
|
-
rowDiv.append(actionContainer);
|
|
970
977
|
}
|
|
971
978
|
|
|
972
979
|
function getAndCleanElement(elementId) {
|
|
@@ -1089,4 +1096,8 @@
|
|
|
1089
1096
|
});
|
|
1090
1097
|
}
|
|
1091
1098
|
|
|
1099
|
+
function doExportToJsonFile() {
|
|
1100
|
+
let jsonName = crops.title.replace(/\s+/g, '-').toLowerCase() + ".json";
|
|
1101
|
+
exportToJsonFile(crops, jsonName);
|
|
1102
|
+
}
|
|
1092
1103
|
</script>
|
package/js/editor-attributes.js
CHANGED
package/js/editor-crops.js
CHANGED
|
@@ -21,6 +21,9 @@ function refreshInterventionsTable() {
|
|
|
21
21
|
let interventionsBottomContainer = getAndCleanElement("interventionsBottomContainer");
|
|
22
22
|
|
|
23
23
|
if (selectedStep && selectedStep.getStep().interventions) {
|
|
24
|
+
// Sort all interventions by day
|
|
25
|
+
selectedStep.getStep().interventions = selectedStep.getStep().interventions.sort((a, b) => a.day - b.day);
|
|
26
|
+
|
|
24
27
|
selectedStep.getStep().interventions.forEach((intervention) => {
|
|
25
28
|
const rowDiv = createInterventionRow(intervention);
|
|
26
29
|
|
|
@@ -29,7 +32,6 @@ function refreshInterventionsTable() {
|
|
|
29
32
|
} else {
|
|
30
33
|
interventionsBottomContainer.appendChild(rowDiv);
|
|
31
34
|
}
|
|
32
|
-
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
}
|
|
@@ -49,17 +51,35 @@ function createInterventionRow(intervention) {
|
|
|
49
51
|
},
|
|
50
52
|
function(id) {
|
|
51
53
|
selectedStep.removeIntervention(id);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
refreshInterventionsTable();
|
|
55
|
+
renderChart();
|
|
56
|
+
},
|
|
57
|
+
function(id) {
|
|
58
|
+
duplicateIntervention(id);
|
|
59
|
+
refreshInterventionsTable();
|
|
60
|
+
renderChart();
|
|
61
|
+
},
|
|
62
|
+
'btn-group-vertical'
|
|
54
63
|
);
|
|
55
64
|
|
|
56
65
|
return rowDiv;
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
function createInterventionNameAndValueColumn(intervention) {
|
|
69
|
+
let absoluteDate = "";
|
|
70
|
+
if (selectedStep && selectedStep.getStep().startDate) {
|
|
71
|
+
const stepStartDate = new Date(selectedStep.getStep().startDate);
|
|
72
|
+
const interventionDate = new Date(stepStartDate);
|
|
73
|
+
interventionDate.setDate(stepStartDate.getDate() + parseInt(intervention.day));
|
|
74
|
+
absoluteDate = interventionDate.toLocaleDateString('fr-FR', {
|
|
75
|
+
month: "short",
|
|
76
|
+
day: "numeric",
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
60
80
|
let nameValueDiv = document.createElement("div");
|
|
61
81
|
nameValueDiv.className = "col";
|
|
62
|
-
nameValueDiv.innerHTML = `<strong>${intervention.name}</strong
|
|
82
|
+
nameValueDiv.innerHTML = `<strong>${intervention.name}</strong> (${absoluteDate})</br> ${intervention.description}`;
|
|
63
83
|
|
|
64
84
|
return nameValueDiv;
|
|
65
85
|
}
|
|
@@ -174,4 +194,24 @@ function updateRelativeDayFromAbsolute() {
|
|
|
174
194
|
|
|
175
195
|
$("#interventionDay").val(dayDiff);
|
|
176
196
|
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function duplicateIntervention(interventionId) {
|
|
200
|
+
if (!selectedStep) return;
|
|
201
|
+
|
|
202
|
+
// Find the intervention to duplicate
|
|
203
|
+
let originalIntervention = selectedStep.getStep().interventions.find(interv => interv.id === interventionId);
|
|
204
|
+
if (!originalIntervention) return;
|
|
205
|
+
|
|
206
|
+
// Create a copy of the intervention
|
|
207
|
+
let newIntervention = {
|
|
208
|
+
id: crypto.randomUUID(),
|
|
209
|
+
day: Number(originalIntervention.day) + 15, // Offset by 15 days to avoid overlap
|
|
210
|
+
name: originalIntervention.name,
|
|
211
|
+
type: originalIntervention.type,
|
|
212
|
+
description: originalIntervention.description
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Add the duplicated intervention to the selected step
|
|
216
|
+
selectedStep.getStep().interventions.push(newIntervention);
|
|
177
217
|
}
|
package/package.json
CHANGED
package/scss/styles-editor.scss
CHANGED
|
@@ -109,13 +109,19 @@ $header-height : 3rem;
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
#cropsContainer
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
#cropsContainer{
|
|
113
|
+
.drag-handle {
|
|
114
|
+
color : #CCC;
|
|
115
|
+
font-weight : normal;
|
|
116
|
+
font-size : 86%;
|
|
117
|
+
margin-right : 10px;
|
|
118
|
+
vertical-align: middle;
|
|
119
|
+
cursor : grab;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
div.col {
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
.form-control {
|
|
@@ -136,4 +142,8 @@ $header-height : 3rem;
|
|
|
136
142
|
text-align : left;
|
|
137
143
|
border : 1px inset;
|
|
138
144
|
background-color: #f1f1f1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#attributeName, #interventionName {
|
|
148
|
+
font-weight: bold;
|
|
139
149
|
}
|