hayun-vite 0.8.0 → 0.9.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/index.js +9 -1
- package/package.json +1 -1
- package/src/Form/Forms.js +36 -34
- package/src/main.js +3 -1
package/index.js
CHANGED
@@ -3,9 +3,17 @@ import dims from './src/Audiogram/dims'
|
|
3
3
|
import logo from './public/vite.svg'
|
4
4
|
import { officeData, patientData } from './data/sampleData'
|
5
5
|
import Forms from './src/Form/Forms'
|
6
|
+
import combo_template from './src/Form/templates/combo'
|
7
|
+
import rasa_aud_template from './src/Form/templates/rasa_audiometry'
|
8
|
+
import rasa_tymp_reflex_template from './src/Form/templates/rasa_tymp_reflex'
|
6
9
|
|
7
10
|
|
8
11
|
|
9
12
|
|
10
13
|
|
11
|
-
|
14
|
+
|
15
|
+
export {
|
16
|
+
logo, Audiogram, Forms, dims, officeData,
|
17
|
+
patientData, combo_template, rasa_aud_template,
|
18
|
+
rasa_tymp_reflex_template
|
19
|
+
}
|
package/package.json
CHANGED
package/src/Form/Forms.js
CHANGED
@@ -2,9 +2,9 @@ const svgNS = "http://www.w3.org/2000/svg";
|
|
2
2
|
|
3
3
|
import printForm from "./printForm.js";
|
4
4
|
import Form from "./Form.js";
|
5
|
-
import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
|
6
|
-
import rasaAud from "./templates/rasa_audiometry.js";
|
7
|
-
import rasaTymp from './templates/rasa_tymp_reflex.js'
|
5
|
+
// import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
|
6
|
+
// import rasaAud from "./templates/rasa_audiometry.js";
|
7
|
+
// import rasaTymp from './templates/rasa_tymp_reflex.js'
|
8
8
|
|
9
9
|
// خط کد زیر لازم هست
|
10
10
|
// import './fonts/Vazirmatn-Regular.woff2'
|
@@ -12,20 +12,18 @@ import '../style.css'
|
|
12
12
|
|
13
13
|
// کلاس جدید که فرمهای مختلف را نمایش میدهد
|
14
14
|
export default class Forms {
|
15
|
-
constructor({ assets, container,
|
15
|
+
constructor({ assets, container, templates, defaultTemplateIndex = 0, mode = 'production' } = {}) {
|
16
16
|
this.container = container
|
17
|
-
|
18
|
-
this.addForms({ templates: [combo],
|
17
|
+
this.mode = mode;
|
18
|
+
// this.addForms({ templates: [rasaAud, rasaTymp, combo], defaultTemplateIndex })
|
19
|
+
this.addForms({ templates, defaultTemplateIndex })
|
19
20
|
}
|
20
21
|
|
21
22
|
// افزودن فرم
|
22
|
-
addForms({ templates,
|
23
|
+
addForms({ templates, defaultTemplateIndex }) {
|
23
24
|
const container = this.container
|
24
25
|
// ایجاد یک دیو برای قرار دادن دکمه ها و لینک های فرم
|
25
26
|
const div = document.createElement('div');
|
26
|
-
container.addEventListener('click', e => {
|
27
|
-
console.log(e.target);
|
28
|
-
})
|
29
27
|
|
30
28
|
div.style = 'border: 1px solid brown; margin: 0; padding: 0;'
|
31
29
|
container.appendChild(div);
|
@@ -36,44 +34,48 @@ export default class Forms {
|
|
36
34
|
|
37
35
|
const forms = []; // آرایه آبجکت های فرم های مختلف
|
38
36
|
this.forms = forms;
|
37
|
+
this.pages = forms
|
39
38
|
|
40
39
|
templates.forEach((template, index) => {
|
41
|
-
btns[index] = this.putButton({ container: div, text: template.label, className });
|
40
|
+
(this.mode == 'develop') && (btns[index] = this.putButton({ container: div, text: template.label, className }));
|
42
41
|
this.forms.push(new Form({ container, template }));
|
43
42
|
});
|
44
43
|
|
45
|
-
const printBtn = this.putButton({ container: div, text: 'چاپ', className });
|
46
|
-
|
47
|
-
// تعریف رویداد دکمه چاپ فرم نمایشی
|
48
|
-
printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) });
|
49
|
-
|
50
44
|
// انتخاب فرم پیشفرض
|
51
|
-
let selectedIndex =
|
45
|
+
let selectedIndex = defaultTemplateIndex;
|
52
46
|
forms[selectedIndex].form.style.display = 'block';
|
53
|
-
this.selectedForm = this.forms[selectedIndex]
|
54
|
-
btns[selectedIndex].style.backgroundColor = ' #1c15e1'
|
47
|
+
this.selectedForm = this.forms[selectedIndex];
|
48
|
+
(this.mode == 'develop') && (btns[selectedIndex].style.backgroundColor = ' #1c15e1');
|
49
|
+
|
50
|
+
console.log(this.mode);
|
51
|
+
|
52
|
+
if (this.mode == 'develop') {
|
55
53
|
|
54
|
+
const printBtn = this.putButton({ container: div, text: 'چاپ', className });
|
55
|
+
// تعریف رویداد دکمه چاپ فرم نمایشی
|
56
|
+
printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) });
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
btns.forEach((btn, index) => {
|
59
|
+
btn.addEventListener('click', () => {
|
60
|
+
// Hide All forms
|
61
|
+
forms.forEach((form, i) => {
|
62
|
+
form.form.style.display = 'none'
|
63
|
+
btns[i].style.backgroundColor = ' #7472e2'
|
63
64
|
|
64
|
-
|
65
|
+
});
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
forms[index].form.style.display = 'block';
|
68
|
+
btns[index].style.backgroundColor = ' #1c15e1'
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
this.selectedForm = forms[index];
|
71
|
+
selectedIndex = index
|
72
|
+
this.update(this.allData);
|
73
|
+
})
|
72
74
|
})
|
73
|
-
})
|
74
75
|
|
75
|
-
|
76
|
-
|
76
|
+
this.putButton({ container: div, text: 'Show/Hide', className })
|
77
|
+
.addEventListener('click', () => { this.toggleDisplay({ container: forms[selectedIndex].form }) });
|
78
|
+
}
|
77
79
|
}
|
78
80
|
|
79
81
|
// این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
|
package/src/main.js
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
import Audiogram from "./Audiogram/Audiogram.js"
|
3
3
|
import Forms from "./Form/Forms.js";
|
4
4
|
import { officeData, patientData } from "../data/sampleData.js"
|
5
|
+
import combo from "./Form/templates/combo.js";
|
6
|
+
|
5
7
|
|
6
8
|
document.querySelector('#app').innerHTML = `
|
7
9
|
<div id="audiogram-div"></div>
|
8
10
|
<div id="forms-div"></div>
|
9
11
|
`;
|
10
12
|
|
11
|
-
const forms = new Forms({ container: document.getElementById('forms-div') });
|
13
|
+
const forms = new Forms({ container: document.getElementById('forms-div'), templates: [combo], mode: 'develop' });
|
12
14
|
forms.update({ officeData, patientData, sessionIndex: 0 })
|
13
15
|
|
14
16
|
/*
|