@osfarm/itineraire-technique 1.1.2 → 1.1.3

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.
@@ -1 +1 @@
1
- div.mainITKContainer{container-type:inline-size;container-name:myparent;line-height:1rem}div.mainITKContainer .left-transcript{display:none;width:50%;font-family:Segoe UI}div.mainITKContainer .chart-div{width:100%}div.mainITKContainer .bottom-transcript{display:block;font-family:Segoe UI}@container myparent (min-width: 800px){div.mainITKContainer .left-transcript{display:block}div.mainITKContainer .chart-div{width:50%}div.mainITKContainer .bottom-transcript{display:none}}@container myparent (min-width: 1200px){div.mainITKContainer .left-transcript{display:block;width:40%}div.mainITKContainer .chart-div{width:60%}div.mainITKContainer .bottom-transcript{display:none}}div.mainITKContainer div.rotation_item{background-color:#f8fafc;border-left:#fff 14px solid;border-radius:7px;padding:8px 3px 5px 9px;margin:12px 0;overflow-x:hidden}div.mainITKContainer div.rotation_item.highlighted{box-shadow:0px 4px 4px 0px var(--UI-Shadow, rgba(17, 36, 69, 0.16)),0px 1px 16px 0px var(--UI-Shadow, rgba(17, 36, 69, 0.16));background-color:#f0f3f5}div.mainITKContainer div.rotation_item div.step-header h4{margin-bottom:0;margin-top:0}div.mainITKContainer div.rotation_item div.step-header div.step_dates{font-size:11px;background-color:#cdcccc;color:#fff;margin:5px;padding:2px 5px;border-radius:5px;height:20px;float:right}div.mainITKContainer div.rotation_item div.step-header div.collapse-button{border-radius:50%;width:30px;height:30px;text-align:center;padding:5px 0px;margin:0 5px 3px 0;cursor:pointer;background:#dfe6f7;color:#7a8bad;float:right;transition:transform .3s ease-in-out}div.mainITKContainer div.rotation_item .step_description{clear:both}div.mainITKContainer div.rotation_item.show-all div.collapse-button{transform:rotate(180deg)}div.mainITKContainer div.rotation_item.show-all div.details{max-height:10000px}div.mainITKContainer div.rotation_item div.details{max-height:0px;overflow:hidden;transition:max-height .3s ease-in-out}div.mainITKContainer div.rotation_item div.details div.intervention{background-color:#fff;border-radius:5px;margin-bottom:11px;padding:13px;cursor:pointer}div.mainITKContainer div.rotation_item div.details div.intervention span.intervention_title{font-weight:bold}div.mainITKContainer div.rotation_item div.details div.intervention span.intervention_date{color:#707070;background-color:#f0f3f5;float:right}div.mainITKContainer div.rotation_item div.details div.intervention div.intervention_description{margin-top:5px}div.mainITKContainer div.rotation_item .step-edit{display:none}div.mainITKContainer .charts{width:100%;height:500px;display:inline-block}div.mainITKContainer .transcript{font-size:80%;width:100%;max-height:450px;overflow-y:scroll;scroll-behavior:smooth;padding:3px}.rotation-tooltip{width:400px}/*# sourceMappingURL=styles-rendering.css.map */
1
+ div.mainITKContainer{container-type:inline-size;container-name:myparent;line-height:1rem}div.mainITKContainer .left-transcript{display:none;width:50%;font-family:Segoe UI}div.mainITKContainer .chart-div{width:100%}div.mainITKContainer .bottom-transcript{display:block;font-family:Segoe UI}@container myparent (min-width: 800px){div.mainITKContainer .left-transcript{display:block}div.mainITKContainer .chart-div{width:50%}div.mainITKContainer .bottom-transcript{display:none}}@container myparent (min-width: 1200px){div.mainITKContainer .left-transcript{display:block;width:40%}div.mainITKContainer .chart-div{width:60%}div.mainITKContainer .bottom-transcript{display:none}}div.mainITKContainer div.rotation_item{background-color:#f8fafc;border-left:#fff 14px solid;border-radius:7px;padding:8px 3px 5px 9px;margin:12px 0;overflow-x:hidden}div.mainITKContainer div.rotation_item.highlighted{box-shadow:0px 4px 4px 0px var(--UI-Shadow, rgba(17, 36, 69, 0.16)),0px 1px 16px 0px var(--UI-Shadow, rgba(17, 36, 69, 0.16));background-color:#f0f3f5}div.mainITKContainer div.rotation_item div.step-header h4{margin-bottom:0;margin-top:0}div.mainITKContainer div.rotation_item div.step-header div.step_dates{font-size:11px;background-color:#cdcccc;color:#fff;margin:5px;padding:2px 5px;border-radius:5px;height:20px;float:right}div.mainITKContainer div.rotation_item div.step-header div.collapse-button{border-radius:50%;width:30px;height:30px;text-align:center;padding:5px 0px;margin:0 5px 3px 0;cursor:pointer;background:#dfe6f7;color:#7a8bad;float:right;transition:transform .3s ease-in-out}div.mainITKContainer div.rotation_item .step_description{clear:both}div.mainITKContainer div.rotation_item.show-all div.collapse-button{transform:rotate(180deg)}div.mainITKContainer div.rotation_item.show-all div.details{max-height:10000px}div.mainITKContainer div.rotation_item div.details{max-height:0px;overflow:hidden;transition:max-height .3s ease-in-out}div.mainITKContainer div.rotation_item div.details div.intervention{background-color:#fff;border-radius:5px;margin-bottom:11px;padding:13px;cursor:pointer}div.mainITKContainer div.rotation_item div.details div.intervention span.intervention_title{font-weight:bold}div.mainITKContainer div.rotation_item div.details div.intervention span.intervention_date{color:#707070;background-color:#f0f3f5;float:right}div.mainITKContainer div.rotation_item div.details div.intervention div.intervention_description{margin-top:5px}div.mainITKContainer div.rotation_item .step-edit{display:none}div.mainITKContainer .charts{width:100%;height:500px;display:inline-block}div.mainITKContainer .transcript{font-size:80%;width:100%;max-height:450px;overflow-y:scroll;scroll-behavior:smooth;padding:3px}.rotation-tooltip{max-width:400px}/*# sourceMappingURL=styles-rendering.css.map */
package/editor.html CHANGED
@@ -663,11 +663,11 @@
663
663
  updateSelectedStep();
664
664
  }
665
665
 
666
- let startDate = new Date();
666
+ let startDate = getRotationEndDate();
667
667
  if (data.average_sowing_date && selectedStep.step.useDefaultStartDate) {
668
668
  // data.average_sowing_date is in MM-DD format, we need to convert it to YYYY-MM-DD
669
669
  // for the current year
670
- let currentYear = new Date().getFullYear();
670
+ let currentYear = startDate.getFullYear();
671
671
  startDate = new Date(`${currentYear}-${data.average_sowing_date}`);
672
672
  // If the start date is before today, it means the crop starts next year
673
673
  if (startDate < new Date()) {
@@ -680,7 +680,7 @@
680
680
  if (data.end_of_season && selectedStep.step.useDefaultEndDate) {
681
681
  // data.end_of_season is in MM-DD format, we need to convert it to YYYY-MM-DD
682
682
  // for the current year
683
- let currentYear = new Date().getFullYear();
683
+ let currentYear = startDate.getFullYear();
684
684
  let endDate = new Date(`${currentYear}-${data.end_of_season}`);
685
685
  // If the end date is before the start date, it means the crop ends the next year
686
686
  if (endDate < startDate) {
@@ -320,7 +320,8 @@ class RotationRenderer {
320
320
  interventionDays: intervention.day,
321
321
  itemStyle: {
322
322
  color: item.color
323
- }
323
+ },
324
+ description: self.getHTMLFormatedDescription(intervention.description)
324
325
  });
325
326
  });
326
327
  }
@@ -664,24 +665,41 @@ class RotationRenderer {
664
665
  },
665
666
  data: []
666
667
  };
667
-
668
- let totalMonths = 0;
669
- let minDate = null;
668
+
670
669
  let lastDayOfPreviousStep = null;
671
670
 
672
671
  steps.forEach((item, index) => {
672
+
673
+ if (lastDayOfPreviousStep) {
674
+ // If there's a gap between the end of the previous step and the start of the new step, we add an dummy pie item:
675
+ let days = Math.round((item.startDate - lastDayOfPreviousStep) / (1000 * 60 * 60 * 24));
676
+ if (days > 0) {
677
+
678
+ let pieItem = {
679
+ 'name': '',
680
+ 'value': days,
681
+ 'divId': '',
682
+ 'type': 'rotation_item',
683
+ 'startDate': new Date(lastDayOfPreviousStep.valueOf()), // Date de début
684
+ 'endDate': new Date(item.startDate.valueOf()), // Date de fin
685
+ 'duration': Math.round(days / 30),
686
+ 'description': '',
687
+ 'emphasis': {'disabled': true},
688
+ 'select': {'disabled': true},
689
+ 'tooltip': {'show': false},
690
+ 'itemStyle': {
691
+ 'color': '#FFFFFF'
692
+ }
693
+ };
694
+
695
+ crops.data.push(pieItem);
696
+ }
697
+ }
698
+
673
699
 
674
- totalMonths += item.duration;
675
-
676
- if (!lastDayOfPreviousStep)
677
- lastDayOfPreviousStep = new Date(item.startDate.valueOf());
678
-
679
- let days = Math.round((item.endDate - lastDayOfPreviousStep) / (1000 * 60 * 60 * 24));
700
+ let days = Math.round((item.endDate - item.startDate) / (1000 * 60 * 60 * 24));
680
701
  lastDayOfPreviousStep = new Date(item.endDate.valueOf());
681
702
 
682
- if (!minDate)
683
- minDate = new Date(item.startDate.valueOf());
684
-
685
703
  let pieItem = {
686
704
  'name': item.name,
687
705
  'value': days,
@@ -718,9 +736,8 @@ class RotationRenderer {
718
736
  itemStyle: {
719
737
  borderColor: '#555',
720
738
  color: '#FFFFFF',
721
- borderWidth: 0
739
+ borderWidth: 1
722
740
  },
723
- emphasis: { disabled: true },
724
741
  data: []
725
742
  };
726
743
 
@@ -740,23 +757,26 @@ class RotationRenderer {
740
757
  ];
741
758
 
742
759
  let monthsPerYear = new Map();
743
- for (let month = 1; month <= totalMonths; month++) {
744
- let monthName = minDate.toLocaleDateString(undefined, { month: 'short' });
745
-
746
- let item = { 'name': monthName, 'value': 1 };
747
- const year = minDate.getFullYear();
748
-
749
- item.itemStyle = { color: monthsColorScale[minDate.getMonth()] };
750
-
751
- months.data.push(item);
760
+ let startMonth = new Date(steps.at(0).startDate.valueOf());
761
+ while (startMonth < steps.at(-1).endDate) {
762
+ const monthName = startMonth.toLocaleDateString(undefined, { month: 'short' });
763
+ const year = startMonth.getFullYear();
764
+
765
+ months.data.push({
766
+ 'name': monthName,
767
+ 'value': 1,
768
+ 'itemStyle': {
769
+ 'color': monthsColorScale[startMonth.getMonth()]
770
+ }
771
+ });
752
772
 
753
773
  let currentMonthsPerYear = monthsPerYear.get(year);
754
774
  if (currentMonthsPerYear == undefined)
755
775
  currentMonthsPerYear = 0;
756
- monthsPerYear.set(year, ++currentMonthsPerYear);
776
+ monthsPerYear.set(year, ++currentMonthsPerYear);
757
777
 
758
778
  // increment the current month
759
- minDate.setMonth(minDate.getMonth() + 1);
779
+ startMonth.setMonth(startMonth.getMonth() + 1);
760
780
  }
761
781
 
762
782
  series.push(months);
@@ -782,7 +802,10 @@ class RotationRenderer {
782
802
  };
783
803
 
784
804
  monthsPerYear.forEach((nbMonths, year) => {
785
- years.data.push({ 'name': year, 'value': nbMonths });
805
+ years.data.push({
806
+ 'name': year,
807
+ 'value': nbMonths
808
+ });
786
809
  });
787
810
 
788
811
  series.push(years);
@@ -841,7 +864,7 @@ class RotationRenderer {
841
864
  else
842
865
  dateString += ' (J' + days + ')';
843
866
 
844
- return params.marker + params.name + ' - ' + dateString;
867
+ return params.marker + params.name + ' - ' + dateString + '<br>' + params.data.description;
845
868
  }
846
869
  }
847
870
  };
@@ -893,4 +916,17 @@ class RotationRenderer {
893
916
 
894
917
  return description;
895
918
  }
919
+
920
+ monthDiff(date1, date2) {
921
+ let anneeDiff = date2.getFullYear() - date1.getFullYear();
922
+ let moisDiff = date2.getMonth() - date1.getMonth();
923
+
924
+ return anneeDiff * 12 + moisDiff;
925
+ }
896
926
  }
927
+
928
+
929
+ // Les mois ne sont pas bien affichés
930
+ // Les dates ne correspondent pas à la rotation (2023 ???)
931
+ // Les trous dans la rotation ne sont pas affichés correctement
932
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfarm/itineraire-technique",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "A visualisation tool to show agricultural technical itineraries based on Echarts",
5
5
  "main": "editor.html",
6
6
  "scripts": {
@@ -158,5 +158,5 @@ div.mainITKContainer {
158
158
  }
159
159
 
160
160
  .rotation-tooltip {
161
- width: 400px;
161
+ max-width: 400px;
162
162
  }