@osfarm/itineraire-technique 1.1.15 → 1.1.17

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/editor.html CHANGED
@@ -293,7 +293,7 @@
293
293
  <select class="form-select" id="saveAsPageSelect" disabled>
294
294
  <option value="">Sélectionner une page...</option>
295
295
  </select>
296
- <div class="form-text">Si non coché, le fichier sera enregistré sous "Non classified"</div>
296
+ <div class="form-text">Si non coché, le fichier sera enregistré sous "Itinéraires techniques non classés"</div>
297
297
  </div>
298
298
  <div class="mb-3">
299
299
  <label for="saveAsFilename" class="form-label">Nom du fichier</label>
@@ -946,7 +946,7 @@
946
946
  return latestEndDate;
947
947
  }
948
948
 
949
- function addEditAndRemoveButtons(rowDiv, deleteId, editFunction, deleteFunction) {
949
+ function addEditAndRemoveButtons(rowDiv, deleteId, editFunction, deleteFunction, duplicateFunction) {
950
950
  rowDiv = $(rowDiv);
951
951
 
952
952
  let actionContainer = $('<div class="col-auto edit-buttons"></div>');
@@ -961,6 +961,11 @@
961
961
  editFunction();
962
962
  }));
963
963
 
964
+ actionContainer.append($('<button class="btn btn-outline-secondary float-end me-1"><i class="fa fa-copy"></i></button>').click(function (event) {
965
+ event.stopPropagation(); // Prevent other onclick events from triggering
966
+ duplicateFunction(deleteId);
967
+ }));
968
+
964
969
  rowDiv.append(actionContainer);
965
970
  }
966
971
 
@@ -78,7 +78,6 @@ class RotationRenderer {
78
78
  }
79
79
 
80
80
  render() {
81
-
82
81
  let self = this;
83
82
 
84
83
  // Initialize the echarts instance based on the prepared dom
@@ -278,6 +277,11 @@ class RotationRenderer {
278
277
  option.series.push(self.getPrecipitationSeries(minMaxDates.min, minMaxDates.max));
279
278
  }
280
279
 
280
+ if (this.data.options?.climate_data?.temperatures.length == 12 &&
281
+ this.data.options?.climate_data?.precipitations.length == 12) {
282
+ option.toolbox.feature.myToolShowClimate.show = true;
283
+ }
284
+
281
285
  return option;
282
286
  }
283
287
 
@@ -1139,12 +1143,20 @@ class RotationRenderer {
1139
1143
  "feature": {
1140
1144
  "myToolShowTranscription": {
1141
1145
  "show": true,
1142
- "title": 'Transcription',
1146
+ "title": 'Afficher la transcription',
1143
1147
  "icon": 'path://m5.57814,0c-3.07871,0 -5.57814,2.49943 -5.57814,5.57813l0,7.14003c0,3.07871 2.49943,5.57814 5.57814,5.57814l7.14002,0c3.07871,0 5.57814,-2.49943 5.57814,-5.57814l0,-7.14003c0,-3.07871 -2.49943,-5.57813 -5.57814,-5.57813l-7.14002,0zm0,1.33875l7.14002,0c2.3602,0 4.23939,1.87918 4.23939,4.23938l0,7.14003c0,2.3602 -1.87919,4.23939 -4.23939,4.23939l-7.14002,0c-2.3602,0 -4.23939,-1.87919 -4.23939,-4.23939l0,-7.14003c0,-2.3602 1.87919,-4.23938 4.23939,-4.23938l0,0zm-1.33875,3.57c-0.36969,0 -0.66938,0.29968 -0.66938,0.66938c0,0.36967 0.29969,0.66938 0.66938,0.66938l9.81752,0c0.36969,0 0.66938,-0.2997 0.66938,-0.66938c0,-0.3697 -0.29969,-0.66938 -0.66938,-0.66938l-9.81752,0zm0,3.57001c-0.36969,0 -0.66938,0.29969 -0.66938,0.66939c0,0.36967 0.29969,0.66938 0.66938,0.66938l9.81752,0c0.36969,0 0.66938,-0.2997 0.66938,-0.66938c0,-0.3697 -0.29969,-0.66939 -0.66938,-0.66939l-9.81752,0zm0,3.57002c-0.36969,0 -0.66938,0.29968 -0.66938,0.66938c0,0.36967 0.29969,0.66938 0.66938,0.66938l9.81752,0c0.36969,0 0.66938,-0.2997 0.66938,-0.66938c0,-0.3697 -0.29969,-0.66938 -0.66938,-0.66938l-9.81752,0z',
1144
1148
  onclick: function () {
1145
1149
  self.toggleTranscription();
1146
1150
  }
1147
1151
  },
1152
+ 'myToolShowClimate': {
1153
+ 'icon': 'path://M18.009 16.932c-1-4-4.8877-7.8876-8.0023-7.8876-3.1146 0-4.5035 1.2325-7.9977 7.8876M19.5893 21H.4107M14.7321 1V17.4286h3.5715V1H16.386ZM8.1964 4.9286v12.5h3.5715v-12.5H8.1964Zm-6.5 3.5357v8.9643H5.2679V8.4643H1.6964Z',
1154
+ 'title': 'Afficher le diagramme ombrothermique',
1155
+ "show": false,
1156
+ onclick: function () {
1157
+ self.showClimateDiagram();
1158
+ }
1159
+ },
1148
1160
  "myToolShowAsDonut": {
1149
1161
  "show": true,
1150
1162
  "title": 'Rotation',
@@ -1195,6 +1207,20 @@ class RotationRenderer {
1195
1207
  this.itk_container.find('.mainITKContainer').toggleClass('withTranscript');
1196
1208
  this.chart.resize();
1197
1209
  }
1210
+
1211
+ showClimateDiagram() {
1212
+ let self = this;
1213
+
1214
+ // Show the climate diagram series
1215
+ self.data.options.show_climate_diagram = !self.data.options.show_climate_diagram;
1216
+
1217
+ let option;
1218
+
1219
+ option = this.getStepsOption();
1220
+
1221
+ self.chart.clear();
1222
+ self.chart.setOption(option, false);
1223
+ }
1198
1224
  }
1199
1225
 
1200
1226
  window.RotationRenderer = RotationRenderer;
@@ -58,6 +58,9 @@ function createCropRow(crop) {
58
58
 
59
59
  refreshAllTables();
60
60
  displayCropListView();
61
+ },
62
+ function(id) {
63
+ duplicateStep(id);
61
64
  });
62
65
 
63
66
  rowDiv.click();
@@ -65,10 +68,66 @@ function createCropRow(crop) {
65
68
  return rowDiv;
66
69
  }
67
70
 
71
+ function duplicateStep(stepId) {
72
+ // Find the step to duplicate
73
+ let originalStep = crops.steps.find(crop => crop.id === stepId);
74
+ if (!originalStep) return;
75
+
76
+ // Get the latest end date in the rotation
77
+ let latestEndDate = getRotationEndDate();
78
+
79
+ // Calculate the duration of the original step
80
+ let originalStart = new Date(originalStep.startDate);
81
+ let originalEnd = new Date(originalStep.endDate);
82
+
83
+ // Calculate how many years to add to position after the latest step
84
+ let yearsToAdd = 0;
85
+ let newStartDate = new Date(originalStart);
86
+ let newEndDate = new Date(originalEnd);
87
+
88
+ // Keep adding years until the new start date is after the latest end date
89
+ while (newStartDate < latestEndDate) {
90
+ yearsToAdd++;
91
+ newStartDate = new Date(originalStart);
92
+ newStartDate.setFullYear(originalStart.getFullYear() + yearsToAdd);
93
+ newEndDate.setFullYear(originalEnd.getFullYear() + yearsToAdd);
94
+ }
95
+
96
+ // Create the new step with all properties cloned
97
+ let newStep = {
98
+ name: originalStep.name,
99
+ color: originalStep.color,
100
+ startDate: newStartDate,
101
+ endDate: newEndDate,
102
+ description: originalStep.description,
103
+ secondary_crop: originalStep.secondary_crop || false,
104
+ useDefaultColor: originalStep.useDefaultColor,
105
+ useDefaultStartDate: originalStep.useDefaultStartDate,
106
+ useDefaultEndDate: originalStep.useDefaultEndDate,
107
+ interventions: originalStep.interventions ? originalStep.interventions.map(i => ({
108
+ day: i.day,
109
+ name: i.name,
110
+ type: i.type,
111
+ description: i.description
112
+ })) : [],
113
+ attributes: originalStep.attributes ? originalStep.attributes.map(a => ({
114
+ name: a.name,
115
+ value: a.value
116
+ })) : []
117
+ };
118
+
119
+ // Create a StepModel instance to ensure proper initialization
120
+ let stepModel = new StepModel(newStep);
121
+
122
+ // Add the duplicated step to the rotation
123
+ crops.steps.push(stepModel.getStep());
124
+
125
+ // Refresh the UI
126
+ refreshAllTables();
127
+ }
68
128
 
69
129
  function SelectStep(crop) {
70
130
  selectedStep = crop;
71
131
  loadSelectedStepToEditor(selectedStep);
72
132
  displayCropDetailView();
73
- refreshAllTables();
74
133
  }
@@ -159,7 +159,7 @@ class WikiEditor {
159
159
  try {
160
160
  // Encode the username for the URL
161
161
  const encodedUsername = 'User:' + username;
162
- const query = encodeURIComponent(`[[Page author::${encodedUsername}]][[A un type de page::+]]`);
162
+ const query = encodeURIComponent(`[[Page author::${encodedUsername}]]`);
163
163
  const url = `/api.php?action=ask&query=${query}|sort=Modification date|order=desc&format=json`;
164
164
 
165
165
  const response = await fetch(url, {
@@ -309,7 +309,7 @@ class WikiEditor {
309
309
  if (useExistingPage && selectedPage) {
310
310
  subpageName = selectedPage;
311
311
  } else {
312
- subpageName = 'Non classified';
312
+ subpageName = 'Itinéraires techniques non classés';
313
313
  }
314
314
 
315
315
  // Build the final URL: subpagename/filename.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfarm/itineraire-technique",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "A visualisation tool to show agricultural technical itineraries based on Echarts",
5
5
  "main": "editor.html",
6
6
  "scripts": {