@osfarm/itineraire-technique 1.0.6 → 1.1.0
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-rendering.css +1 -1
- package/css/styles-rendering.css.map +1 -1
- package/editor.html +5 -2
- package/js/chart-render.js +14 -6
- package/js/editor-wiki-editor.js +103 -0
- package/package.json +1 -1
- package/scss/styles-rendering.scss +1 -1
package/css/styles-rendering.css
CHANGED
|
@@ -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}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}/*# 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}/*# sourceMappingURL=styles-rendering.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../scss/styles-rendering.scss"],"names":[],"mappings":"AAAA,qBACI,2BACA,wBACA,iBAEA,sCACI,aACA,UACA,qBAGJ,gCACI,WAGJ,wCACI,cACA,qBAGJ,uCACI,sCACI,cAGJ,gCACI,UAGJ,wCACI,cAIR,wCACI,sCACI,cACA,UAGJ,gCACI,UAGJ,wCACI,cAIR,uCACI,yBACA,4BACA,kBACA,wBACA,cACA,kBAEA,mDACI,8HAEA,
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../scss/styles-rendering.scss"],"names":[],"mappings":"AAAA,qBACI,2BACA,wBACA,iBAEA,sCACI,aACA,UACA,qBAGJ,gCACI,WAGJ,wCACI,cACA,qBAGJ,uCACI,sCACI,cAGJ,gCACI,UAGJ,wCACI,cAIR,wCACI,sCACI,cACA,UAGJ,gCACI,UAGJ,wCACI,cAIR,uCACI,yBACA,4BACA,kBACA,wBACA,cACA,kBAEA,mDACI,8HAEA,yBAIA,0DACI,gBACA,aAGJ,sEACI,eACA,yBACA,WACA,WACA,gBACA,kBACA,YACA,YAGJ,2EACI,kBACA,WACA,YACA,kBACA,gBACA,mBACA,eACA,mBACA,cACA,YACA,qCAIR,yDACI,WAIA,oEACI,yBAGJ,4DACI,mBAKR,mDACI,eACA,gBACA,sCAEA,oEACI,sBACA,kBACA,mBACA,aACA,eAEA,4FACI,iBAGJ,2FACI,cACA,yBACA,YAGJ,iGACI,eAKZ,kDACI,aAIR,6BACI,WACA,aACA,qBAGJ,iCACI,cACA,WACA,iBACA,kBACA,uBACA","file":"styles-rendering.css"}
|
package/editor.html
CHANGED
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
<script src="./js/editor-interventions.js"></script>
|
|
21
21
|
<script src="./js/editor-crops.js"></script>
|
|
22
22
|
<script src="./js/editor-export.js"></script>
|
|
23
|
+
<script src="./js/editor-wiki-editor.js"></script>
|
|
23
24
|
|
|
24
25
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
25
26
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
26
27
|
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
|
27
28
|
<link href="./css/styles-editor.css" rel="stylesheet">
|
|
28
|
-
<link href="./css/styles-rendering.css" rel="stylesheet">
|
|
29
|
+
<link href="./css/styles-rendering.css" rel="stylesheet">
|
|
29
30
|
</head>
|
|
30
31
|
|
|
31
32
|
<body>
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
<button type="button" onclick="importFromJsonFile()" class="btn btn-outline-primary primary-button"
|
|
36
37
|
id="importFromJsonButton"><i class="fa fa-upload" aria-hidden="true"></i> Charger (JSON)</button>
|
|
37
38
|
<button type="button" onclick="importFromTestJson()" class="btn btn-outline-primary primary-button"
|
|
38
|
-
id="
|
|
39
|
+
id="importFromExampleJsonButton"><i class="fa fa-upload" aria-hidden="true"></i> Charger un
|
|
39
40
|
exemple</button>
|
|
40
41
|
<button type="button" onclick="exportToJsonFile(crops)"
|
|
41
42
|
class="btn btn-outline-primary primary-button" id="exportToJsonButton"><i
|
|
@@ -379,6 +380,8 @@
|
|
|
379
380
|
|
|
380
381
|
refreshAllTables();
|
|
381
382
|
});
|
|
383
|
+
|
|
384
|
+
let we = new WikiEditor();
|
|
382
385
|
}
|
|
383
386
|
|
|
384
387
|
class StepModel {
|
package/js/chart-render.js
CHANGED
|
@@ -29,12 +29,20 @@ class RotationRenderer {
|
|
|
29
29
|
|
|
30
30
|
this.itk_container = $("#" + divID).css({ 'width': '100%' });
|
|
31
31
|
|
|
32
|
-
if (this.
|
|
33
|
-
this.itk_container.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
if (this.data.options.show_transcript) {
|
|
33
|
+
if (this.itk_container.find('.mainITKContainer').length == 0) {
|
|
34
|
+
this.itk_container.append(`<div class="row mainITKContainer">
|
|
35
|
+
<div class="col-auto left-transcript"><div class="transcript"></div></div>
|
|
36
|
+
<div class="col col-auto chart-div"><div class="charts"></div></div>
|
|
37
|
+
<div class="col col-12 bottom-transcript"><div class="transcript"></div></div>
|
|
38
|
+
</div>`);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
if (this.itk_container.find('.mainITKContainer').length == 0) {
|
|
42
|
+
this.itk_container.append(`<div class="row mainITKContainer">
|
|
43
|
+
<div class="col col-12 chart-div"><div class="charts"></div></div>
|
|
44
|
+
</div>`);
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Encapsulate the wiki editor functionality
|
|
2
|
+
class WikiEditor {
|
|
3
|
+
constructor() {
|
|
4
|
+
// Initialize any properties if needed
|
|
5
|
+
|
|
6
|
+
const self = this;
|
|
7
|
+
|
|
8
|
+
// When the page loads, get the URL paremeter with the target page title we want to edit:
|
|
9
|
+
window.onload = function () {
|
|
10
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
11
|
+
const pageTitle = urlParams.get('wiki');
|
|
12
|
+
|
|
13
|
+
if (!pageTitle)
|
|
14
|
+
return; // No page title provided, we are not in wiki edit mode
|
|
15
|
+
|
|
16
|
+
// If a page title is provided, load its content
|
|
17
|
+
fetch(`/api.php?action=parse&page=${encodeURIComponent(pageTitle)}&format=json&prop=wikitext`, {
|
|
18
|
+
credentials: 'same-origin'
|
|
19
|
+
})
|
|
20
|
+
.then(response => {
|
|
21
|
+
let res = response.json();
|
|
22
|
+
return res;
|
|
23
|
+
})
|
|
24
|
+
.then(data => {
|
|
25
|
+
if (data.parse && data.parse.wikitext) {
|
|
26
|
+
try {
|
|
27
|
+
const content = JSON.parse(data.parse.wikitext['*']);
|
|
28
|
+
reloadCropsFromJson(content);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error("Erreur lors de l'analyse du JSON de la page :", e);
|
|
31
|
+
$('#jsonErrorMessage').text("Le contenu de la page n'est pas un JSON valide.");
|
|
32
|
+
const jsonErrorModal = new bootstrap.Modal(document.getElementById('jsonErrorModal'));
|
|
33
|
+
jsonErrorModal.show();
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
|
|
37
|
+
if (data.error.code == "missingtitle") {
|
|
38
|
+
// The page doesn't exist yet, we can start with a blank rotation
|
|
39
|
+
wipe();
|
|
40
|
+
} else {
|
|
41
|
+
console.error("Erreur lors du chargement de la page :", data);
|
|
42
|
+
$('#jsonErrorMessage').text("Impossible de charger le contenu de la page.");
|
|
43
|
+
const jsonErrorModal = new bootstrap.Modal(document.getElementById('jsonErrorModal'));
|
|
44
|
+
jsonErrorModal.show();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Add a button to save the page back the wiki
|
|
51
|
+
const saveButton = $(`<button type="button" class="btn btn-outline-primary primary-button" id="exportToJsonButton">
|
|
52
|
+
<i class="fa fa-download" aria-hidden="true"></i> Enregistrer dans le wiki
|
|
53
|
+
</button>`).on('click', function () {
|
|
54
|
+
if (pageTitle) {
|
|
55
|
+
// If a page title is provided, save to that page
|
|
56
|
+
self.savePageToWiki(pageTitle, JSON.stringify(crops, null, 2))
|
|
57
|
+
.then(() => {
|
|
58
|
+
alert("Itinéraire technique enregistré avec succès !");
|
|
59
|
+
})
|
|
60
|
+
.catch(err => {
|
|
61
|
+
console.error("Erreur lors de l'enregistrement de la page :", err);
|
|
62
|
+
alert("Une erreur s'est produite lors de l'enregistrement.");
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
// Otherwise, export to JSON file
|
|
66
|
+
exportToJsonFile(crops);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
$(".file-icons").first().prepend(saveButton);
|
|
71
|
+
|
|
72
|
+
$('#importFromExampleJsonButton').remove();
|
|
73
|
+
$('#importFromJsonButton').remove();
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async savePageToWiki(pageTitle, newContent) {
|
|
78
|
+
// 1. Obtenir un token
|
|
79
|
+
const tokenResp = await fetch('/api.php?action=query&meta=tokens&type=csrf&format=json', {
|
|
80
|
+
credentials: 'same-origin' // important pour envoyer les cookies de session
|
|
81
|
+
});
|
|
82
|
+
const tokenData = await tokenResp.json();
|
|
83
|
+
const token = tokenData.query.tokens.csrftoken;
|
|
84
|
+
|
|
85
|
+
// 2. Faire l’édition
|
|
86
|
+
const params = new URLSearchParams();
|
|
87
|
+
params.append('action', 'edit');
|
|
88
|
+
params.append('format', 'json');
|
|
89
|
+
params.append('title', pageTitle);
|
|
90
|
+
params.append('text', newContent);
|
|
91
|
+
params.append('token', token);
|
|
92
|
+
params.append('contentmodel', 'json');
|
|
93
|
+
|
|
94
|
+
const editResp = await fetch('/api.php', {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
body: params,
|
|
97
|
+
credentials: 'same-origin'
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const editData = await editResp.json();
|
|
101
|
+
console.log(editData);
|
|
102
|
+
}
|
|
103
|
+
}
|
package/package.json
CHANGED