Compare commits
448 Commits
v2.35.0
...
9041101505
| Author | SHA1 | Date | |
|---|---|---|---|
| 9041101505 | |||
|
|
d3fda0be37 | ||
|
|
41de21201e | ||
|
|
005f85c34f | ||
|
|
6bb6125e81 | ||
|
|
4da2b844e8 | ||
|
|
eba1923b7c | ||
|
|
f28823dbe9 | ||
|
|
5d122bca7d | ||
|
|
ef4321586c | ||
|
|
336511dcd5 | ||
|
|
d73b6f9026 | ||
|
|
e959c0172d | ||
|
|
a15767c14f | ||
|
|
20b1743223 | ||
|
|
a89930fae6 | ||
|
|
60e81a921e | ||
|
|
36f75beea9 | ||
|
|
01a9eab73d | ||
|
|
a4eff5ae38 | ||
|
|
46b5495167 | ||
|
|
7c9ef2a702 | ||
|
|
ee9aed6bbc | ||
|
|
eb4cf6e2db | ||
|
|
c6ad6b495c | ||
|
|
5499a86854 | ||
|
|
627ccd8214 | ||
|
|
e760d59d9f | ||
|
|
e76858121f | ||
|
|
34f1d02803 | ||
|
|
64610050ca | ||
|
|
f5bd52a94d | ||
|
|
ce603cac1e | ||
|
|
3108235521 | ||
|
|
280aaecf76 | ||
|
|
ba0bb1eabc | ||
|
|
73d0755249 | ||
|
|
4d93dcb9b4 | ||
|
|
1fc9b8e279 | ||
|
|
c6d05111cc | ||
|
|
8fa3d8ba4a | ||
|
|
c5317beb3f | ||
|
|
7d82e36790 | ||
|
|
f39867b0e2 | ||
|
|
54cef503ad | ||
|
|
ce51371e62 | ||
|
|
7aabbbd497 | ||
|
|
02b89ea137 | ||
|
|
119a48f3a3 | ||
|
|
3146a0354c | ||
|
|
8e895a9890 | ||
|
|
ac436cbf79 | ||
|
|
4363aa7734 | ||
|
|
a65cb073b5 | ||
|
|
a3b9e4f7b2 | ||
|
|
ebde8a0171 | ||
|
|
684299ac3b | ||
|
|
c449aef7ae | ||
|
|
879a27ed0a | ||
|
|
107e7a4e31 | ||
|
|
fa0325106a | ||
|
|
bbfce9363f | ||
|
|
10a6280b78 | ||
|
|
08e8724b4c | ||
|
|
555c7e4e2d | ||
|
|
3673026a33 | ||
|
|
cd565ec160 | ||
|
|
bdcbae03ef | ||
|
|
296234a093 | ||
|
|
10c0955c6c | ||
|
|
8ba2bfda63 | ||
|
|
cb06cc53c2 | ||
|
|
826828ba30 | ||
|
|
22de38c72b | ||
|
|
0037c01beb | ||
|
|
fb17c666a9 | ||
|
|
2c32fac1f2 | ||
|
|
3f0b00decd | ||
|
|
160c7863f0 | ||
|
|
c4d185f2d6 | ||
|
|
6b13b1231a | ||
|
|
661137d500 | ||
|
|
962dcc1ce9 | ||
|
|
655df62d6c | ||
|
|
d827a10c84 | ||
|
|
25c640fabb | ||
|
|
0cb8d21290 | ||
|
|
7a47591967 | ||
|
|
6931ca27c3 | ||
|
|
d00d2de1cc | ||
|
|
b1be568991 | ||
|
|
28be3891d2 | ||
|
|
27d2297e2b | ||
|
|
7212ddd5c5 | ||
|
|
f4e9ac5bf1 | ||
|
|
8fec484d66 | ||
|
|
bcf781c37b | ||
|
|
d8a8e689d0 | ||
|
|
a844b95de3 | ||
|
|
ece885f973 | ||
|
|
66dd30604b | ||
|
|
d0f0f4905c | ||
|
|
c9cb6702b6 | ||
|
|
1ddb980242 | ||
|
|
94b626a4d2 | ||
|
|
d2a011462d | ||
|
|
4c34926af0 | ||
|
|
ce35cd1009 | ||
|
|
56d072bd06 | ||
|
|
5d336ef669 | ||
|
|
b47c59eac1 | ||
|
|
87285db361 | ||
|
|
84312e498c | ||
|
|
bd763d9462 | ||
|
|
a00e66f786 | ||
|
|
78c7b52088 | ||
|
|
c3a5bee993 | ||
|
|
c2b5b7c3e2 | ||
|
|
3992f00353 | ||
|
|
97d853e0d3 | ||
|
|
f786cec75f | ||
|
|
07cd08b55e | ||
|
|
ca42faf14a | ||
|
|
87f5b68279 | ||
|
|
6b31edb687 | ||
|
|
6a64048bb6 | ||
|
|
6cf069ee6a | ||
|
|
3b74bba6ab | ||
|
|
8689788523 | ||
|
|
1193776d06 | ||
|
|
022514a0a7 | ||
|
|
dc7f8a59ed | ||
|
|
4e5a76a6c1 | ||
|
|
64c4a25ee8 | ||
|
|
47bbdbaa26 | ||
|
|
f8e0c0e19a | ||
|
|
94cdd19224 | ||
|
|
d86d046eb0 | ||
|
|
25ec6b5a3f | ||
|
|
967453a683 | ||
|
|
4c17305c05 | ||
|
|
6092131303 | ||
|
|
35749834d0 | ||
|
|
fe56c7b887 | ||
|
|
2b58a744d2 | ||
|
|
dfb94d05e4 | ||
|
|
987c1790d8 | ||
|
|
0d416b17ce | ||
|
|
473e165c89 | ||
|
|
3d52d15004 | ||
|
|
27278e128c | ||
|
|
13cee3c9b3 | ||
|
|
fd95e42e9b | ||
|
|
65cd2f5d01 | ||
|
|
70759d1888 | ||
|
|
705d6e2f00 | ||
|
|
088591a335 | ||
|
|
3f037e0d17 | ||
|
|
e6884b6c93 | ||
|
|
9943268ca0 | ||
|
|
620e4d20c2 | ||
|
|
fd03033ac6 | ||
|
|
939099b8c8 | ||
|
|
75001b494d | ||
|
|
8749e21744 | ||
|
|
982ac98e27 | ||
|
|
f31bf17a41 | ||
|
|
3425d9118d | ||
|
|
6be49ecdf3 | ||
|
|
ffd6f9578b | ||
|
|
41293130ad | ||
|
|
6cccd28b92 | ||
|
|
384f10a722 | ||
|
|
a603e299f1 | ||
|
|
05822f82da | ||
|
|
0508e718cb | ||
|
|
574913e9e4 | ||
|
|
068adb62a7 | ||
|
|
73fa1f9cfe | ||
|
|
f518882926 | ||
|
|
ed566f9eea | ||
|
|
8ca32e439a | ||
|
|
35b3b11a3c | ||
|
|
57d4a53081 | ||
|
|
6da05961f2 | ||
|
|
7db3b8c5b8 | ||
|
|
50bafb6fa6 | ||
|
|
2b3a9072d1 | ||
|
|
1c08e57086 | ||
|
|
4290ed2f04 | ||
|
|
342512f3e1 | ||
|
|
942c04cb68 | ||
|
|
64bf4ab3f7 | ||
|
|
052e69737e | ||
|
|
02adc4517c | ||
|
|
e36fdd6823 | ||
|
|
d10a7ed57f | ||
|
|
79adf44dfe | ||
|
|
4bc3113f34 | ||
|
|
0826704282 | ||
|
|
52aa5e6954 | ||
|
|
fde85607d9 | ||
|
|
cc087af012 | ||
|
|
2c7da1e32e | ||
|
|
49fe8952ae | ||
|
|
b298cd0509 | ||
|
|
a81fc11e73 | ||
|
|
199fb6229d | ||
|
|
ec6ecee455 | ||
|
|
fa72172b77 | ||
|
|
6789700def | ||
|
|
752744b3a4 | ||
|
|
c24fa85bf4 | ||
|
|
4e0b59f6a9 | ||
|
|
bd20214552 | ||
|
|
4af0ea9e47 | ||
|
|
8651679634 | ||
|
|
99dcac6d12 | ||
|
|
853bf01c9e | ||
|
|
39c5ad7267 | ||
|
|
8daa2948fa | ||
|
|
f2ba25429e | ||
|
|
1fffb4dc67 | ||
|
|
45ce2439fd | ||
|
|
cb2e77e8f6 | ||
|
|
800c0b0336 | ||
|
|
14c23496d5 | ||
|
|
7756a6d593 | ||
|
|
ae7791a204 | ||
|
|
44232c44fc | ||
|
|
142fc99761 | ||
|
|
5e6dc55c76 | ||
|
|
bb2447e821 | ||
|
|
a88d9cd78e | ||
|
|
dab82db693 | ||
|
|
a1183df72c | ||
|
|
5cfa4f173a | ||
|
|
451ef49d98 | ||
|
|
36a8ebdc1b | ||
|
|
27577edb16 | ||
|
|
bd69ab314b | ||
|
|
6abe4ac04a | ||
|
|
1eeb190653 | ||
|
|
23f22d9d9a | ||
|
|
b913f33b3f | ||
|
|
52da1feb91 | ||
|
|
0af9f1bfbf | ||
|
|
3b0e1c3ce7 | ||
|
|
37ea270c56 | ||
|
|
304550dd94 | ||
|
|
69cee24ffe | ||
|
|
8334c06a9b | ||
|
|
3e739f2877 | ||
|
|
5e33ff4a34 | ||
|
|
2b234e5d64 | ||
|
|
c8b328a1c9 | ||
|
|
5e0ac05f90 | ||
|
|
e440097272 | ||
|
|
263c858a66 | ||
|
|
82371fb2a8 | ||
|
|
b6336a4096 | ||
|
|
7acfbbaae7 | ||
|
|
5a76b4eb2d | ||
|
|
8aac88b696 | ||
|
|
d6e71068be | ||
|
|
6b44951ef0 | ||
|
|
5289ebb923 | ||
|
|
263fcda053 | ||
|
|
2e0d26575e | ||
|
|
b9d6670bee | ||
|
|
f20d39a3e7 | ||
|
|
09d948b3a0 | ||
|
|
96941c83f3 | ||
|
|
b8ca0e381a | ||
|
|
4a2c5d77aa | ||
|
|
cf2d29d82e | ||
|
|
fb2ab63550 | ||
|
|
90efc152a8 | ||
|
|
de6ba49409 | ||
|
|
9d4196f15a | ||
|
|
eed7fb970d | ||
|
|
fe67f1ab61 | ||
|
|
78640561f5 | ||
|
|
f72631a262 | ||
|
|
670e5d0202 | ||
|
|
ea59d1158a | ||
|
|
ba23cf9789 | ||
|
|
de585b90ea | ||
|
|
cf40f4e525 | ||
|
|
b273e34ac8 | ||
|
|
1a00d708e1 | ||
|
|
583584d8c5 | ||
|
|
09c087dee7 | ||
|
|
f5cff50674 | ||
|
|
81c48d5182 | ||
|
|
c44414cadb | ||
|
|
85db4be514 | ||
|
|
6526eefaf5 | ||
|
|
bd1fc5d705 | ||
|
|
ca547023b0 | ||
|
|
caf57d355b | ||
|
|
7e6da62480 | ||
|
|
e14e560415 | ||
|
|
0a8ac87cee | ||
|
|
42441aafd6 | ||
|
|
9c3ff958e3 | ||
|
|
efac7af750 | ||
|
|
314935f68e | ||
|
|
1efa857d95 | ||
|
|
a7409b498e | ||
|
|
a9cb0a8c26 | ||
|
|
9333affaf1 | ||
|
|
38a32be503 | ||
|
|
fe5f7daf78 | ||
|
|
3c07c3e1cf | ||
|
|
cb87c75ac0 | ||
|
|
62ead16817 | ||
|
|
6352e4deb1 | ||
|
|
0c4b569be6 | ||
|
|
fe4d7cfb75 | ||
|
|
d3e791b017 | ||
|
|
0849183d26 | ||
|
|
3410af8899 | ||
|
|
81a1e3a4c3 | ||
|
|
c8e18dc445 | ||
|
|
ad21bd6f53 | ||
|
|
781457fce3 | ||
|
|
6662b713f1 | ||
|
|
34c0d16411 | ||
|
|
f7003ecbbe | ||
|
|
134090df5d | ||
|
|
efb4feab2e | ||
|
|
900e959b0b | ||
|
|
946ffeb3ca | ||
|
|
56d32b0674 | ||
|
|
03fc5c084a | ||
|
|
2a32355dd8 | ||
|
|
d80d0e9d9b | ||
|
|
be0388ee6e | ||
|
|
414c41162a | ||
|
|
39106de96c | ||
|
|
8adb76abfb | ||
|
|
4889b04283 | ||
|
|
e9973a242b | ||
|
|
d324ad0ac5 | ||
|
|
ab6cc2698a | ||
|
|
da076f71a1 | ||
|
|
63c1fe8e75 | ||
|
|
31f0833629 | ||
|
|
d4dc094049 | ||
|
|
21a84e8032 | ||
|
|
819a1baae0 | ||
|
|
b0ee67faff | ||
|
|
0684bd105a | ||
|
|
5c948862a0 | ||
|
|
23291b38de | ||
|
|
9357bd55a6 | ||
|
|
e51d668418 | ||
|
|
a48df70631 | ||
|
|
9853e8311b | ||
|
|
cd8041b048 | ||
|
|
00bf5b7ad6 | ||
|
|
40bcc983c7 | ||
|
|
dfb26f31db | ||
|
|
a57a0bebef | ||
|
|
4853621b1b | ||
|
|
e3209c6fb3 | ||
|
|
13d25cce1f | ||
|
|
cb16b0ca64 | ||
|
|
b3ce3159e7 | ||
|
|
76ffc70892 | ||
|
|
2734587981 | ||
|
|
223e93d654 | ||
|
|
26351726a8 | ||
|
|
efc84db580 | ||
|
|
3bf58bb6f0 | ||
|
|
a7962d9404 | ||
|
|
5ce9bb306d | ||
|
|
5b5bb38f4f | ||
|
|
419ad311a0 | ||
|
|
0c3af09566 | ||
|
|
c9063625ec | ||
|
|
205858a41d | ||
|
|
87edad17c3 | ||
|
|
1c54e80951 | ||
|
|
6c19cdc729 | ||
|
|
84a703bb50 | ||
|
|
27ed95b044 | ||
|
|
0358dfe790 | ||
|
|
68cee65f22 | ||
|
|
24b2125b97 | ||
|
|
eceed12992 | ||
|
|
f9028433a0 | ||
|
|
1936e7b212 | ||
|
|
c04a972be3 | ||
|
|
9c26b011e4 | ||
|
|
821f125789 | ||
|
|
e0f376880a | ||
|
|
6da77bb3c7 | ||
|
|
2fd660a93f | ||
|
|
f3eefc748a | ||
|
|
4852698d74 | ||
|
|
36b24dc826 | ||
|
|
d60bc1d4b6 | ||
|
|
06a02c0877 | ||
|
|
1a53a9f30b | ||
|
|
7ee81d4693 | ||
|
|
0a32d03fda | ||
|
|
6c43dfea18 | ||
|
|
7d1e226743 | ||
|
|
8ea903b81a | ||
|
|
24b08599b3 | ||
|
|
a0f1c1f227 | ||
|
|
efbb014588 | ||
|
|
f881a0e1d5 | ||
|
|
acdb81e8a3 | ||
|
|
6559a87323 | ||
|
|
8301bab768 | ||
|
|
eb0b2010f9 | ||
|
|
8158ea164d | ||
|
|
beb3134af9 | ||
|
|
5fdc6a21a5 | ||
|
|
e7516c57bc | ||
|
|
2169d81b73 | ||
|
|
1d6bb9f9f6 | ||
|
|
812bd07d03 | ||
|
|
19bb02f905 | ||
|
|
58d750f726 | ||
|
|
7f3bb58ec1 | ||
|
|
08ceaf204f | ||
|
|
eced1221a8 | ||
|
|
3a5bbde0cc | ||
|
|
eb1a790485 | ||
|
|
21e9c85bf7 | ||
|
|
632f783d57 | ||
|
|
3ba3908108 | ||
|
|
903a4e91b0 | ||
|
|
6496b129ce | ||
|
|
9fff7a2ea8 | ||
|
|
6d94617e59 | ||
|
|
b95d07babb | ||
|
|
9748d075fa | ||
|
|
aaeeb84ed3 | ||
|
|
c3702ee6d5 | ||
|
|
f239987043 | ||
|
|
6aa67c3fae | ||
|
|
1fc5d75cc0 | ||
|
|
bcfd3bb636 |
178
README.md
178
README.md
@@ -1,178 +0,0 @@
|
||||
<div align="center" markdown="1">
|
||||
|
||||
<img src=".github/lms-logo.png" alt="Frappe Learning logo" width="80" height="80"/>
|
||||
<h1>Frappe Learning</h1>
|
||||
|
||||
**Easy to use, open source, Learning Management System**
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div align="center">
|
||||
<img src=".github/hero.png?v=5" alt="Hero Image" width="72%" />
|
||||
</div>
|
||||
<br />
|
||||
<div align="center">
|
||||
<a href="https://frappe.io/learning">Website</a>
|
||||
-
|
||||
<a href="https://docs.frappe.io/learning">Documentation</a>
|
||||
</div>
|
||||
|
||||
## Frappe Learning
|
||||
Frappe Learning is an easy-to-use learning system that helps you bring structure to your content.
|
||||
|
||||
### Motivation
|
||||
In 2021, we were looking for a Learning Management System to launch [Mon.School](https://mon.school) for FOSS United. We checked out Moodle, but it didn’t feel right. The forms were unnecessarily lengthy and the UI was confusing. It shouldn't be this hard to create a course right? So I started making a learning system for Mon.School which soon became a product in itself. The aim is to have a simple platform that anyone can use to launch a course of their own and make knowledge sharing easier.
|
||||
|
||||
### Key Features
|
||||
|
||||
- **Structured Learning**: Design a course with a 3-level hierarchy, where your courses have chapters and you can group your lessons within these chapters. This ensures that the context of the lesson is set by the chapter.
|
||||
|
||||
- **Live Classes**: Group learners into batches based on courses and duration. You can then create Zoom live class for these batches right from the app. Learners get to see the list of live classes they have to take as a part of this batch.
|
||||
|
||||
- **Quizzes and Assignments**: Create quizzes where questions can have single-choice, multiple-choice options, or can be open ended. Instructors can also add assignments which learners can submit as PDF's or Documents.
|
||||
|
||||
- **Getting Certified**: Once a learner has completed the course or batch, you can grant them a certificate. The app provides an inbuilt certificate template. You can use this or else create a template of your own and use that instead.
|
||||
|
||||
<details>
|
||||
<summary>View Screenshots</summary>
|
||||
|
||||
|
||||

|
||||
<div align="center">
|
||||
<sub>
|
||||
Create batches to group your learners
|
||||
</sub>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
|
||||

|
||||
<div align="center">
|
||||
<sub>
|
||||
Evaluate their knowledge by quizzes
|
||||
</sub>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
|
||||

|
||||
<div align="center">
|
||||
<sub>
|
||||
Autenticate their work with certification
|
||||
</sub>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
|
||||
### Under the Hood
|
||||
|
||||
- [**Frappe Framework**](https://github.com/frappe/frappe): A full-stack web application framework.
|
||||
|
||||
- [**Frappe UI**](https://github.com/frappe/frappe-ui): A Vue-based UI library, to provide a modern user interface.
|
||||
|
||||
## Production Setup
|
||||
|
||||
### Managed Hosting
|
||||
|
||||
You can try [Frappe Cloud](https://frappecloud.com), a simple, user-friendly and sophisticated [open-source](https://github.com/frappe/press) platform to host Frappe applications with peace of mind.
|
||||
|
||||
It takes care of installation, setup, upgrades, monitoring, maintenance and support of your Frappe deployments. It is a fully featured developer platform with an ability to manage and control multiple Frappe deployments.
|
||||
|
||||
<div>
|
||||
<a href="https://frappecloud.com/lms/signup" target="_blank">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://frappe.io/files/try-on-fc-white.png">
|
||||
<img src="https://frappe.io/files/try-on-fc-black.png" alt="Try on Frappe Cloud" height="28" />
|
||||
</picture>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
### Self Hosting
|
||||
|
||||
Follow these steps to set up Frappe Learning in production:
|
||||
|
||||
**Step 1**: Download the easy install script
|
||||
|
||||
```bash
|
||||
wget https://frappe.io/easy-install.py
|
||||
```
|
||||
|
||||
**Step 2**: Run the deployment command
|
||||
|
||||
```bash
|
||||
python3 ./easy-install.py deploy \
|
||||
--project=learning_prod_setup \
|
||||
--email=your_email.example.com \
|
||||
--image=ghcr.io/frappe/lms \
|
||||
--version=stable \
|
||||
--app=lms \
|
||||
--sitename subdomain.domain.tld
|
||||
```
|
||||
|
||||
Replace the following parameters with your values:
|
||||
- `your_email.example.com`: Your email address
|
||||
- `subdomain.domain.tld`: Your domain name where Learning will be hosted
|
||||
|
||||
The script will set up a production-ready instance of Frappe Learning with all the necessary configurations in about 5 minutes.
|
||||
|
||||
**Note:** To avoid a `404 Page Not Found` error:
|
||||
- If hosting on a **public server**, make sure your DNS **A record** points to your server's IP.
|
||||
- If hosting **locally**, map your domain to `127.0.0.1` in your `/etc/hosts` file:
|
||||
|
||||
## Development Setup
|
||||
|
||||
### Docker
|
||||
|
||||
You need Docker, docker-compose and git setup on your machine. Refer [Docker documentation](https://docs.docker.com/). After that, follow below steps:
|
||||
|
||||
**Step 1**: Setup folder and download the required files
|
||||
|
||||
mkdir frappe-learning
|
||||
cd frappe-learning
|
||||
|
||||
# Download the docker-compose file
|
||||
wget -O docker-compose.yml https://raw.githubusercontent.com/frappe/lms/develop/docker/docker-compose.yml
|
||||
|
||||
# Download the setup script
|
||||
wget -O init.sh https://raw.githubusercontent.com/frappe/lms/develop/docker/init.sh
|
||||
|
||||
**Step 2**: Run the container and daemonize it
|
||||
|
||||
docker compose up -d
|
||||
|
||||
**Step 3**: The site [http://lms.localhost:8000/lms](http://lms.localhost:8000/lms) should now be available. The default credentials are:
|
||||
- Username: Administrator
|
||||
- Password: admin
|
||||
|
||||
### Local
|
||||
|
||||
To setup the repository locally follow the steps mentioned below:
|
||||
|
||||
1. Install bench and setup a `frappe-bench` directory by following the [Installation Steps](https://frappeframework.com/docs/user/en/installation)
|
||||
1. Start the server by running `bench start`
|
||||
1. In a separate terminal window, create a new site by running `bench new-site learning.test`
|
||||
1. Map your site to localhost with the command `bench --site learning.test add-to-hosts`
|
||||
1. Get the Learning app. Run `bench get-app https://github.com/frappe/lms`
|
||||
1. Run `bench --site learning.test install-app lms`.
|
||||
1. Now open the URL `http://learning.test:8000/lms` in your browser, you should see the app running
|
||||
|
||||
## Learn and connect
|
||||
|
||||
- [Telegram Public Group](https://t.me/frappelms)
|
||||
- [Discuss Forum](https://discuss.frappe.io/c/lms/70)
|
||||
- [Documentation](https://docs.frappe.io/learning)
|
||||
- [YouTube](https://www.youtube.com/channel/UCn3bV5kx77HsVwtnlCeEi_A)
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<div align="center" style="padding-top: 0.75rem;">
|
||||
<a href="https://frappe.io" target="_blank">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://frappe.io/files/Frappe-white.png">
|
||||
<img src="https://frappe.io/files/Frappe-black.png" alt="Frappe Technologies" height="28"/>
|
||||
</picture>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -10,11 +10,11 @@ describe("Batch Creation", () => {
|
||||
cy.get("span").contains("Settings").click();
|
||||
|
||||
// Add a new member
|
||||
cy.get('[id^="headlessui-dialog-panel-v-"]')
|
||||
cy.get("[data-dismissable-layer]")
|
||||
.find("span")
|
||||
.contains(/^Members$/)
|
||||
.click();
|
||||
cy.get('[id^="headlessui-dialog-panel-v-"]')
|
||||
cy.get("[data-dismissable-layer]")
|
||||
.find("button")
|
||||
.contains("New")
|
||||
.click();
|
||||
@@ -28,12 +28,12 @@ describe("Batch Creation", () => {
|
||||
cy.get("button").contains("Add").click();
|
||||
|
||||
// Add evaluator
|
||||
cy.get('[id^="headlessui-dialog-panel-v-"]')
|
||||
cy.get("[data-dismissable-layer]")
|
||||
.find("span")
|
||||
.contains(/^Evaluators$/)
|
||||
.click();
|
||||
|
||||
cy.get('[id^="headlessui-dialog-panel-v-"]')
|
||||
cy.get("[data-dismissable-layer]")
|
||||
.find("button")
|
||||
.contains("New")
|
||||
.click();
|
||||
@@ -156,11 +156,7 @@ describe("Batch Creation", () => {
|
||||
|
||||
/* Add student to batch */
|
||||
cy.get("button").contains("Add").click();
|
||||
cy.get('div[id^="headlessui-dialog-panel-v-"]')
|
||||
.first()
|
||||
.find("button")
|
||||
.eq(1)
|
||||
.click();
|
||||
cy.get('div[role="dialog"]').first().find("button").eq(1).click();
|
||||
cy.get("input[id^='headlessui-combobox-input-v-']").type(randomEmail);
|
||||
cy.get("div").contains(randomEmail).click();
|
||||
cy.get("button").contains("Submit").click();
|
||||
|
||||
@@ -76,7 +76,7 @@ describe("Course Creation", () => {
|
||||
cy.button("Add Chapter").click();
|
||||
|
||||
cy.wait(1000);
|
||||
cy.get("[id^=headlessui-dialog-panel-")
|
||||
cy.get("[data-dismissable-layer]")
|
||||
.should("be.visible")
|
||||
.within(() => {
|
||||
cy.get("label").contains("Title").type("Test Chapter");
|
||||
@@ -143,7 +143,7 @@ describe("Course Creation", () => {
|
||||
cy.get("span").contains("Community").click();
|
||||
cy.button("New Question").click();
|
||||
cy.wait(500);
|
||||
cy.get("[id^=headlessui-dialog-panel-").within(() => {
|
||||
cy.get("[data-dismissable-layer]").within(() => {
|
||||
cy.get("label").contains("Title").type("Test Discussion");
|
||||
cy.get("div[contenteditable=true]").invoke(
|
||||
"text",
|
||||
|
||||
Submodule frappe-ui updated: 8cd9b06a5e...f1bde9bcb2
8
frontend/components.d.ts
vendored
8
frontend/components.d.ts
vendored
@@ -10,6 +10,7 @@ declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
Annoucements: typeof import('./src/components/Annoucements.vue')['default']
|
||||
AnnouncementModal: typeof import('./src/components/Modals/AnnouncementModal.vue')['default']
|
||||
AppHeader: typeof import('./src/components/AppHeader.vue')['default']
|
||||
Apps: typeof import('./src/components/Apps.vue')['default']
|
||||
AppSidebar: typeof import('./src/components/AppSidebar.vue')['default']
|
||||
AssessmentModal: typeof import('./src/components/Modals/AssessmentModal.vue')['default']
|
||||
@@ -41,6 +42,7 @@ declare module 'vue' {
|
||||
CodeEditor: typeof import('./src/components/Controls/CodeEditor.vue')['default']
|
||||
CollapseSidebar: typeof import('./src/components/Icons/CollapseSidebar.vue')['default']
|
||||
ColorSwatches: typeof import('./src/components/Controls/ColorSwatches.vue')['default']
|
||||
ContactUsEmail: typeof import('./src/components/ContactUsEmail.vue')['default']
|
||||
CourseCard: typeof import('./src/components/CourseCard.vue')['default']
|
||||
CourseCardOverlay: typeof import('./src/components/CourseCardOverlay.vue')['default']
|
||||
CourseInstructors: typeof import('./src/components/CourseInstructors.vue')['default']
|
||||
@@ -71,6 +73,7 @@ declare module 'vue' {
|
||||
InviteIcon: typeof import('./src/components/Icons/InviteIcon.vue')['default']
|
||||
JobApplicationModal: typeof import('./src/components/Modals/JobApplicationModal.vue')['default']
|
||||
JobCard: typeof import('./src/components/JobCard.vue')['default']
|
||||
LayoutHeader: typeof import('./src/components/LayoutHeader.vue')['default']
|
||||
LessonContent: typeof import('./src/components/LessonContent.vue')['default']
|
||||
LessonHelp: typeof import('./src/components/LessonHelp.vue')['default']
|
||||
Link: typeof import('./src/components/Controls/Link.vue')['default']
|
||||
@@ -86,7 +89,8 @@ declare module 'vue' {
|
||||
Notes: typeof import('./src/components/Notes/Notes.vue')['default']
|
||||
NotPermitted: typeof import('./src/components/NotPermitted.vue')['default']
|
||||
PageModal: typeof import('./src/components/Modals/PageModal.vue')['default']
|
||||
PaymentSettings: typeof import('./src/components/Settings/PaymentSettings.vue')['default']
|
||||
PaymentGatewayDetails: typeof import('./src/components/Settings/PaymentGatewayDetails.vue')['default']
|
||||
PaymentGateways: typeof import('./src/components/Settings/PaymentGateways.vue')['default']
|
||||
Play: typeof import('./src/components/Icons/Play.vue')['default']
|
||||
ProgressBar: typeof import('./src/components/ProgressBar.vue')['default']
|
||||
Question: typeof import('./src/components/Modals/Question.vue')['default']
|
||||
@@ -105,6 +109,8 @@ declare module 'vue' {
|
||||
StudentHeatmap: typeof import('./src/components/StudentHeatmap.vue')['default']
|
||||
StudentModal: typeof import('./src/components/Modals/StudentModal.vue')['default']
|
||||
Tags: typeof import('./src/components/Tags.vue')['default']
|
||||
TransactionDetails: typeof import('./src/components/Settings/TransactionDetails.vue')['default']
|
||||
Transactions: typeof import('./src/components/Settings/Transactions.vue')['default']
|
||||
UnsplashImageBrowser: typeof import('./src/components/UnsplashImageBrowser.vue')['default']
|
||||
UpcomingEvaluations: typeof import('./src/components/UpcomingEvaluations.vue')['default']
|
||||
Uploader: typeof import('./src/components/Controls/Uploader.vue')['default']
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="{{ favicon }}" />
|
||||
<link rel="manifest" href="/api/method/lms.lms.api.get_pwa_manifest" />
|
||||
<link rel="apple-touch-icon" href="public/manifest/apple-icon-180.png" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="theme-color" content="#FFFFFF" media="(prefers-color-scheme: light)" />
|
||||
@@ -212,7 +213,7 @@
|
||||
<meta name="twitter:image" content="{{ meta.image }}" />
|
||||
<meta name="twitter:description" content="{{ meta.description }}" />
|
||||
</head>
|
||||
<body>
|
||||
<body class="sm:overscroll-y-none no-scrollbar">
|
||||
<div id="app">
|
||||
<div id="seo-content">
|
||||
<h1>{{ meta.title }}</h1>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"dayjs": "^1.11.6",
|
||||
"dompurify": "^3.2.6",
|
||||
"feather-icons": "^4.28.0",
|
||||
"frappe-ui": "0.1.173",
|
||||
"frappe-ui": "^0.1.201",
|
||||
"highlight.js": "^11.11.1",
|
||||
"lucide-vue-next": "^0.383.0",
|
||||
"markdown-it": "^14.0.0",
|
||||
@@ -54,6 +54,7 @@
|
||||
"@vitejs/plugin-vue": "^5.0.3",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"postcss": "^8.4.5",
|
||||
"vite": "^5.0.11"
|
||||
"vite": "^5.0.11",
|
||||
"vite-plugin-pwa": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
frontend/public/leaderboard/bronze-cup.png
Normal file
BIN
frontend/public/leaderboard/bronze-cup.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
42
frontend/public/leaderboard/dart-board.svg
Normal file
42
frontend/public/leaderboard/dart-board.svg
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 512.001 512.001" xml:space="preserve">
|
||||
<g>
|
||||
<path style="fill:#A67C52;" d="M84.096,436.178l-49.312,37.686c-7.54,5.762-8.981,16.547-3.219,24.087
|
||||
c3.383,4.425,8.494,6.751,13.666,6.751c3.638,0,7.306-1.151,10.421-3.532l49.312-37.686c7.54-5.762,8.981-16.547,3.219-24.087
|
||||
C102.421,431.858,91.637,430.416,84.096,436.178z"/>
|
||||
<path style="fill:#A67C52;" d="M441.194,473.864l-49.312-37.686c-7.541-5.762-18.325-4.32-24.087,3.219
|
||||
c-5.762,7.541-4.321,18.325,3.219,24.087l49.312,37.686c3.115,2.38,6.782,3.532,10.421,3.532c5.171,0,10.284-2.326,13.665-6.751
|
||||
C450.175,490.411,448.734,479.627,441.194,473.864z"/>
|
||||
</g>
|
||||
<path style="fill:#DBAD75;" d="M237.989,36.024c-131.227,0-237.989,106.761-237.989,237.989s106.761,237.989,237.989,237.989
|
||||
S475.978,405.24,475.978,274.012S369.216,36.024,237.989,36.024z"/>
|
||||
<path style="fill:#EABD81;" d="M237.989,36.024c-131.227,0-237.989,106.761-237.989,237.989s106.761,237.989,237.989,237.989V36.024
|
||||
z"/>
|
||||
<path style="fill:#BC2A46;" d="M237.989,80.411c-106.752,0-193.601,86.849-193.601,193.601s86.849,193.601,193.601,193.601
|
||||
s193.601-86.849,193.601-193.601S344.742,80.411,237.989,80.411z"/>
|
||||
<path style="fill:#D62D46;" d="M237.989,80.411c-106.752,0-193.601,86.849-193.601,193.601s86.849,193.601,193.601,193.601V80.411z"
|
||||
/>
|
||||
<path style="fill:#DBAD75;" d="M237.989,142.771c-72.367,0-131.241,58.874-131.241,131.241s58.874,131.241,131.241,131.241
|
||||
S369.23,346.379,369.23,274.012S310.355,142.771,237.989,142.771z"/>
|
||||
<path style="fill:#EABD81;" d="M237.989,142.771c-72.367,0-131.241,58.874-131.241,131.241s58.874,131.241,131.241,131.241V142.771z
|
||||
"/>
|
||||
<path style="fill:#BC2A46;" d="M237.989,209.763c-35.427,0-64.248,28.821-64.248,64.248s28.821,64.248,64.248,64.248
|
||||
s64.248-28.821,64.248-64.248S273.416,209.763,237.989,209.763z"/>
|
||||
<path style="fill:#D62D46;" d="M237.989,209.763c-35.427,0-64.248,28.821-64.248,64.248s28.821,64.248,64.248,64.248V209.763z"/>
|
||||
<path style="fill:#CFCDD6;" d="M237.989,291.196c-4.398,0-8.796-1.677-12.15-5.034c-6.711-6.711-6.711-17.59,0-24.301
|
||||
L448.687,39.014c6.71-6.711,17.59-6.711,24.301,0s6.711,17.59,0,24.301L250.14,286.162
|
||||
C246.784,289.519,242.386,291.196,237.989,291.196z"/>
|
||||
<path style="fill:#DEE1E7;" d="M237.989,291.196c-4.398,0-8.796-1.677-12.15-5.034c-6.711-6.711-6.711-17.59,0-24.301
|
||||
l106.576-106.576l24.301,24.301L250.14,286.162C246.784,289.519,242.386,291.196,237.989,291.196z"/>
|
||||
<path style="fill:#39B7B6;" d="M457.533,105.266h-33.615c-9.49,0-17.184-7.694-17.184-17.184V54.467
|
||||
c0-9.49,7.694-17.184,17.184-17.184s17.184,7.694,17.184,17.184v16.432h16.431c9.49,0,17.184,7.694,17.184,17.184
|
||||
S467.023,105.266,457.533,105.266z"/>
|
||||
<path style="fill:#FBB03B;" d="M476.175,86.623h-33.614c-9.49,0-17.184-7.694-17.184-17.184V35.825
|
||||
c0-9.49,7.694-17.184,17.184-17.184s17.184,7.694,17.184,17.184v16.431h16.431c9.49,0,17.184,7.694,17.184,17.184
|
||||
S485.665,86.623,476.175,86.623z"/>
|
||||
<path style="fill:#39B7B6;" d="M494.817,67.982h-33.614c-9.49,0-17.184-7.694-17.184-17.184V17.184
|
||||
c0-9.49,7.694-17.184,17.184-17.184s17.184,7.694,17.184,17.184v16.431h16.431c9.49,0,17.184,7.694,17.184,17.184
|
||||
S504.308,67.982,494.817,67.982z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
BIN
frontend/public/leaderboard/gold-cup.png
Normal file
BIN
frontend/public/leaderboard/gold-cup.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
frontend/public/leaderboard/silver-cup.png
Normal file
BIN
frontend/public/leaderboard/silver-cup.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
2
frontend/public/leaderboard/star.svg
Normal file
2
frontend/public/leaderboard/star.svg
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--noto" preserveAspectRatio="xMidYMid meet"><path d="M68.05 7.23l13.46 30.7a7.047 7.047 0 0 0 5.82 4.19l32.79 2.94c3.71.54 5.19 5.09 2.5 7.71l-24.7 20.75c-2 1.68-2.91 4.32-2.36 6.87l7.18 33.61c.63 3.69-3.24 6.51-6.56 4.76L67.56 102a7.033 7.033 0 0 0-7.12 0l-28.62 16.75c-3.31 1.74-7.19-1.07-6.56-4.76l7.18-33.61c.54-2.55-.36-5.19-2.36-6.87L5.37 52.78c-2.68-2.61-1.2-7.17 2.5-7.71l32.79-2.94a7.047 7.047 0 0 0 5.82-4.19l13.46-30.7c1.67-3.36 6.45-3.36 8.11-.01z" fill="#fdd835"></path><path d="M67.07 39.77l-2.28-22.62c-.09-1.26-.35-3.42 1.67-3.42c1.6 0 2.47 3.33 2.47 3.33l6.84 18.16c2.58 6.91 1.52 9.28-.97 10.68c-2.86 1.6-7.08.35-7.73-6.13z" fill="#ffff8d"></path><path d="M95.28 71.51L114.9 56.2c.97-.81 2.72-2.1 1.32-3.57c-1.11-1.16-4.11.51-4.11.51l-17.17 6.71c-5.12 1.77-8.52 4.39-8.82 7.69c-.39 4.4 3.56 7.79 9.16 3.97z" fill="#f4b400"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1,11 +1,9 @@
|
||||
<template>
|
||||
<FrappeUIProvider>
|
||||
<Layout>
|
||||
<div class="text-base">
|
||||
<router-view />
|
||||
</div>
|
||||
<Layout class="isolate text-base">
|
||||
<router-view />
|
||||
</Layout>
|
||||
<InstallPrompt v-if="isMobile" />
|
||||
<!--<InstallPrompt v-if="isMobile" />-->
|
||||
<Dialogs />
|
||||
</FrappeUIProvider>
|
||||
</template>
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
>
|
||||
<UserDropdown :isCollapsed="sidebarStore.isSidebarCollapsed" />
|
||||
<div class="flex flex-col" v-if="sidebarSettings.data">
|
||||
<SidebarLink
|
||||
v-for="link in sidebarLinks"
|
||||
:link="link"
|
||||
:isCollapsed="sidebarStore.isSidebarCollapsed"
|
||||
class="mx-2 my-0.5"
|
||||
/>
|
||||
<div v-for="link in sidebarLinks" class="mx-2 my-0.5">
|
||||
<SidebarLink
|
||||
:link="link"
|
||||
:isCollapsed="sidebarStore.isSidebarCollapsed"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
||||
@@ -54,15 +54,18 @@
|
||||
class="flex flex-col transition-all duration-300 ease-in-out"
|
||||
:class="!sidebarStore.isWebpagesCollapsed ? 'block' : 'hidden'"
|
||||
>
|
||||
<SidebarLink
|
||||
<div
|
||||
v-for="link in sidebarSettings.data.web_pages"
|
||||
:link="link"
|
||||
:isCollapsed="sidebarStore.isSidebarCollapsed"
|
||||
class="mx-2 my-0.5"
|
||||
:showControls="isModerator ? true : false"
|
||||
@openModal="openPageModal"
|
||||
@deletePage="deletePage"
|
||||
/>
|
||||
>
|
||||
<SidebarLink
|
||||
:link="link"
|
||||
:isCollapsed="sidebarStore.isSidebarCollapsed"
|
||||
:showControls="isModerator ? true : false"
|
||||
@openModal="openPageModal"
|
||||
@deletePage="deletePage"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -375,6 +378,18 @@ const addPrograms = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const addContactUsDetails = () => {
|
||||
if (settingsStore.contactUsEmail?.data || settingsStore.contactUsURL?.data) {
|
||||
sidebarLinks.value.push({
|
||||
label: 'Contact Us',
|
||||
icon: settingsStore.contactUsURL?.data ? 'Headset' : 'Mail',
|
||||
to: settingsStore.contactUsURL?.data
|
||||
? settingsStore.contactUsURL.data
|
||||
: settingsStore.contactUsEmail?.data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const checkIfCanAddProgram = async () => {
|
||||
if (isModerator.value || isInstructor.value) {
|
||||
return true
|
||||
@@ -594,6 +609,11 @@ const articles = ref([
|
||||
{ name: 'create-a-live-class', title: __('Create a live class') },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: __('Learning Paths'),
|
||||
opened: false,
|
||||
subArticles: [{ name: 'add-a-program', title: __('Add a program') }],
|
||||
},
|
||||
{
|
||||
title: __('Assessments'),
|
||||
opened: false,
|
||||
@@ -639,7 +659,106 @@ const setUpOnboarding = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const addMyPoints = () => {
|
||||
const roles = userResource.data?.roles || []
|
||||
if (roles.includes('LMS Student') || roles.includes('LMS Schoolchild')) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('My points'),
|
||||
icon: 'Award',
|
||||
to: 'MyPoints',
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const addLeaderBoard = () => {
|
||||
if (user) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('Leader Board'),
|
||||
icon: 'Trophy',
|
||||
to: 'LeaderBoard',
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const addChatGPT = () => {
|
||||
const roles = userResource.data?.roles || []
|
||||
let URL = ''
|
||||
let nameLabel = ''
|
||||
if (roles.includes('LMS Schoolchild') || roles.includes('LMS Student') || roles.includes('Course Creator')) {
|
||||
if (roles.includes('LMS Schoolchild')) {
|
||||
URL = 'chatgpt-schoolchild'
|
||||
nameLabel = __('ChatGPT for Schoolers')
|
||||
} else if (roles.includes('LMS Student')) {
|
||||
URL = 'chatgpt-schoolchild'
|
||||
nameLabel = __('ChatGPT for Students')
|
||||
} else if (roles.includes('Course Creator')) {
|
||||
URL = 'ai-teachers'
|
||||
nameLabel = __('ChatGPT for Teachers')
|
||||
}
|
||||
|
||||
sidebarLinks.value.push({
|
||||
label: nameLabel,
|
||||
icon: 'Cpu',
|
||||
to: URL,
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const addMyChild = () => {
|
||||
const roles = userResource.data?.roles || []
|
||||
if (roles.includes('Parent')) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('My Child'),
|
||||
icon: 'User',
|
||||
to: 'my-child',
|
||||
activeFor: [],
|
||||
external: true,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//test of new page
|
||||
const addProfile = () => {
|
||||
const roles = userResource.data?.roles || []
|
||||
if (roles.includes('LMS Student')) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('Student Profile'),
|
||||
icon: 'Home',
|
||||
to: 'StudentProfile',
|
||||
activeFor: [],
|
||||
})
|
||||
} else if (roles.includes('LMS Schoolchild')) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('Schoolchildren Profile'),
|
||||
icon: 'Home',
|
||||
to: 'SchoolchildrenProfile',
|
||||
activeFor: [],
|
||||
})
|
||||
} else if (roles.includes('Course Creator')) {
|
||||
sidebarLinks.value.push({
|
||||
label: __('Course Creator Profile'),
|
||||
icon: 'Home',
|
||||
to: 'CourseCreatorProfile',
|
||||
activeFor: [],
|
||||
})
|
||||
} else {
|
||||
sidebarLinks.value.push({
|
||||
label: __('Parent Profile'),
|
||||
icon: 'Home',
|
||||
to: 'ParentProfile',
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
watch(userResource, () => {
|
||||
addContactUsDetails()
|
||||
if (userResource.data) {
|
||||
isModerator.value = userResource.data.is_moderator
|
||||
isInstructor.value = userResource.data.is_instructor
|
||||
@@ -649,6 +768,12 @@ watch(userResource, () => {
|
||||
addQuizzes()
|
||||
addAssignments()
|
||||
setUpOnboarding()
|
||||
|
||||
addMyPoints()
|
||||
addLeaderBoard()
|
||||
addChatGPT()
|
||||
addMyChild()
|
||||
addProfile()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
<FileUploader
|
||||
v-if="!submissionFile"
|
||||
:fileTypes="getType()"
|
||||
:uploadArgs="{
|
||||
private: true,
|
||||
}"
|
||||
:validateFile="validateFile"
|
||||
@success="(file) => saveSubmission(file)"
|
||||
>
|
||||
@@ -127,6 +130,9 @@
|
||||
@change="(val) => (answer = val)"
|
||||
:editable="true"
|
||||
:fixedMenu="true"
|
||||
:uploadArgs="{
|
||||
private: true,
|
||||
}"
|
||||
editorClass="prose-sm max-w-none border-b border-x bg-surface-gray-2 rounded-b-md py-1 px-2 min-h-[7rem]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
67
frontend/src/components/ContactUsEmail.vue
Normal file
67
frontend/src/components/ContactUsEmail.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
title: __('Contact Us'),
|
||||
size: 'md',
|
||||
}"
|
||||
>
|
||||
<template #body-content>
|
||||
<div class="flex flex-col gap-4">
|
||||
<FormControl
|
||||
v-model="subject"
|
||||
:label="__('Subject')"
|
||||
type="text"
|
||||
:required="true"
|
||||
/>
|
||||
<div>
|
||||
<div class="mb-1.5 text-sm text-ink-gray-5">
|
||||
{{ __('Message') }}
|
||||
<span class="text-ink-red-3">*</span>
|
||||
</div>
|
||||
<TextEditor
|
||||
:fixedMenu="true"
|
||||
@change="(val) => (message = val)"
|
||||
editorClass="prose-sm py-2 px-2 min-h-[200px] border-outline-gray-2 hover:border-outline-gray-3 rounded-b-md bg-surface-gray-3"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions="{ close }">
|
||||
<div class="pb-5 float-right">
|
||||
<Button variant="solid" @click="sendMail(close)">
|
||||
{{ __('Send') }}
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Button, call, Dialog, FormControl, TextEditor, toast } from 'frappe-ui'
|
||||
import { ref } from 'vue'
|
||||
import { useSettings } from '@/stores/settings'
|
||||
|
||||
const show = defineModel<boolean>({ required: true, default: false })
|
||||
const subject = ref('')
|
||||
const message = ref('')
|
||||
const settingsStore = useSettings()
|
||||
|
||||
const sendMail = (close: Function) => {
|
||||
call('frappe.core.doctype.communication.email.make', {
|
||||
recipients: settingsStore.contactUsEmail?.data,
|
||||
subject: subject.value,
|
||||
content: message.value,
|
||||
send_email: true,
|
||||
})
|
||||
.then(() => {
|
||||
toast.success(__('Email sent successfully'))
|
||||
close()
|
||||
subject.value = ''
|
||||
message.value = ''
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error(__('Failed to send email'))
|
||||
close()
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -37,7 +37,7 @@
|
||||
</slot>
|
||||
</template>
|
||||
<template #body="{ isOpen }">
|
||||
<div v-show="isOpen">
|
||||
<div v-show="isOpen" class="">
|
||||
<div
|
||||
class="mt-1 rounded-lg bg-surface-white py-1 text-base border-2"
|
||||
>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
style="min-height: 350px"
|
||||
>
|
||||
<div
|
||||
class="w-[100%] h-[168px] bg-cover bg-center bg-no-repeat"
|
||||
class="w-[100%] h-[168px] bg-cover bg-center bg-no-repeat border-t border-x rounded-t-md"
|
||||
:style="
|
||||
course.image
|
||||
? { backgroundImage: `url('${encodeURI(course.image)}')` }
|
||||
@@ -62,7 +62,7 @@
|
||||
<Tooltip :text="__('Enrolled Students')">
|
||||
<span class="flex items-center">
|
||||
<Users class="h-4 w-4 stroke-1.5 mr-1" />
|
||||
{{ course.enrollments }}
|
||||
{{ formatAmount(course.enrollments) }}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
@@ -116,27 +116,30 @@
|
||||
<CourseInstructors :instructors="course.instructors" />
|
||||
</div>
|
||||
|
||||
<div v-if="course.paid_course" class="font-semibold">
|
||||
{{ course.price }}
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div v-if="course.paid_course" class="font-semibold">
|
||||
{{ course.price }}
|
||||
</div>
|
||||
|
||||
<Tooltip
|
||||
v-if="course.paid_certificate || course.enable_certification"
|
||||
:text="__('Get Certified')"
|
||||
>
|
||||
<GraduationCap class="size-5 stroke-1.5 text-ink-gray-7" />
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
v-if="course.paid_certificate || course.enable_certification"
|
||||
:text="__('Get Certified')"
|
||||
>
|
||||
<GraduationCap class="size-5 stroke-1.5 text-ink-gray-7" />
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Award, BookOpen, GraduationCap, Star, Users } from 'lucide-vue-next'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { Tooltip } from 'frappe-ui'
|
||||
import { theme } from '@/utils/theme'
|
||||
import { formatAmount } from '@/utils'
|
||||
import CourseInstructors from '@/components/CourseInstructors.vue'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import ProgressBar from '@/components/ProgressBar.vue'
|
||||
|
||||
const { user } = sessionStore()
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<CourseProgressSummary
|
||||
v-if="user.data?.is_moderator || is_instructor()"
|
||||
v-model="showProgressModal"
|
||||
:courseName="course.data.name"
|
||||
:enrollments="course.data.enrollments"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<div class="">
|
||||
<div class="text-ink-gray-7">
|
||||
<span v-if="instructors?.length == 1">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'Profile',
|
||||
params: { username: instructors[0].username },
|
||||
}"
|
||||
class="text-ink-gray-7 hover:text-ink-gray-9"
|
||||
>
|
||||
{{ instructors[0].full_name }}
|
||||
</router-link>
|
||||
@@ -16,6 +17,7 @@
|
||||
name: 'Profile',
|
||||
params: { username: instructors[0].username },
|
||||
}"
|
||||
class="text-ink-gray-7 hover:text-ink-gray-9"
|
||||
>
|
||||
{{ instructors[0].first_name }}
|
||||
</router-link>
|
||||
@@ -25,6 +27,7 @@
|
||||
name: 'Profile',
|
||||
params: { username: instructors[1].username },
|
||||
}"
|
||||
class="text-ink-gray-7 hover:text-ink-gray-9"
|
||||
>
|
||||
{{ instructors[1].first_name }}
|
||||
</router-link>
|
||||
@@ -35,6 +38,7 @@
|
||||
name: 'Profile',
|
||||
params: { username: instructors[0].username },
|
||||
}"
|
||||
class="text-ink-gray-7 hover:text-ink-gray-9"
|
||||
>
|
||||
{{ instructors[0].first_name }}
|
||||
</router-link>
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
<template>
|
||||
<div class="relative flex h-full flex-col">
|
||||
<div class="h-full flex-1">
|
||||
<div class="flex h-screen text-base bg-surface-white">
|
||||
<div
|
||||
class="relative block min-h-0 flex-shrink-0 overflow-hidden hover:overflow-auto"
|
||||
>
|
||||
<AppSidebar />
|
||||
</div>
|
||||
<div class="w-full overflow-auto" id="scrollContainer">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex h-screen w-screen">
|
||||
<div class="h-full border-r bg-surface-menu-bar">
|
||||
<AppSidebar />
|
||||
</div>
|
||||
<div class="flex-1 flex flex-col h-full overflow-auto bg-surface-white">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<Popover :show="iosInstallMessage" placement="top">
|
||||
<Popover :show="iosInstallMessage" placement="top-start">
|
||||
<template #body>
|
||||
<div
|
||||
class="fixed bottom-[4rem] left-1/2 -translate-x-1/2 z-20 w-[90%] flex flex-col gap-3 rounded bg-blue-100 py-5 drop-shadow-xl"
|
||||
class="fixed top-[20rem] translate-x-1/3 z-20 flex flex-col gap-3 rounded bg-surface-white py-5 drop-shadow-xl"
|
||||
>
|
||||
<div
|
||||
class="mb-1 flex flex-row items-center justify-between px-3 text-center"
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="px-3 text-xs text-gray-800">
|
||||
<span class="flex flex-col gap-2">
|
||||
<span>
|
||||
<span class="leading-5">
|
||||
{{
|
||||
__(
|
||||
'Get the app on your iPhone for easy access & a better experience'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
class="flex flex-col border rounded-md p-3 h-full hover:border-outline-gray-3"
|
||||
>
|
||||
<div class="flex space-x-4 mb-4">
|
||||
<div class="flex flex-col space-y-2 flex-1">
|
||||
<div class="flex flex-col space-y-2 flex-1 break-all">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ job.company_name }}
|
||||
</div>
|
||||
@@ -33,6 +33,9 @@
|
||||
<Badge>
|
||||
{{ job.type }}
|
||||
</Badge>
|
||||
<Badge v-if="job.work_mode">
|
||||
{{ job.work_mode }}
|
||||
</Badge>
|
||||
<Badge>
|
||||
{{ dayjs(job.creation).fromNow() }}
|
||||
</Badge>
|
||||
|
||||
@@ -9,6 +9,16 @@
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-if="rutube">
|
||||
<iframe
|
||||
class="rutube-video"
|
||||
:src="getRutubeVideoSource(rutube.split('/').pop())"
|
||||
width="100%"
|
||||
:height="screenSize.width < 640 ? 200 : 400"
|
||||
frameborder="0"
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-for="block in content?.split('\n\n')">
|
||||
<div v-if="block.includes('{{ YouTubeVideo')">
|
||||
<iframe
|
||||
@@ -20,6 +30,16 @@
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-else-if="block.includes('{{ RutubeVideo')">
|
||||
<iframe
|
||||
class="rutube-video"
|
||||
:src="getRutubeVideoSource(block)"
|
||||
width="100%"
|
||||
:height="screenSize.width < 640 ? 200 : 400"
|
||||
frameborder="0"
|
||||
allowfullscreen
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-else-if="block.includes('{{ Quiz')">
|
||||
<Quiz :quiz="getId(block)" />
|
||||
</div>
|
||||
@@ -97,6 +117,13 @@ const getYouTubeVideoSource = (block) => {
|
||||
return `https://www.youtube.com/embed/${block}`
|
||||
}
|
||||
|
||||
const getRutubeVideoSource = (block) => {
|
||||
if (block.includes('{{')) {
|
||||
block = getId(block)
|
||||
}
|
||||
return `https://rutube.ru/play/embed/${block}`
|
||||
}
|
||||
|
||||
const getPDFSource = (block) => {
|
||||
return `${getId(block)}#toolbar=0`
|
||||
}
|
||||
@@ -105,3 +132,11 @@ const getId = (block) => {
|
||||
return block.match(/\(["']([^"']+?)["']\)/)[1]
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.youtube-video,
|
||||
.rutube-video {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -52,9 +52,9 @@ const contentMap = {
|
||||
'To upload Image, Video, Audio or PDF from your system, click on the add icon and select upload from the menu. Then choose the file you want to add to the lesson and it gets added to your lesson.',
|
||||
},
|
||||
youtube: {
|
||||
title: 'How to add a YouTube Video?',
|
||||
title: 'How to add a YouTube Video/RuTube?',
|
||||
description:
|
||||
'Copy the URL of the video from YouTube and paste it in the editor.',
|
||||
'Copy the URL of the video from YouTube/RuTube and paste it in the editor.',
|
||||
},
|
||||
remove: {
|
||||
title: 'How to remove an embed?',
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
<div class="flex items-center space-x-2">
|
||||
<Clock class="w-4 h-4 stroke-1.5" />
|
||||
<span>
|
||||
{{ formatTime(cls.time) }} -
|
||||
{{ dayjs(getClassEnd(cls)).format('HH:mm A') }}
|
||||
{{ dayjs(getClassStart(cls)).format('hh:mm A') }} -
|
||||
{{ dayjs(getClassEnd(cls)).format('hh:mm A') }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
@@ -181,8 +181,12 @@ const canAccessClass = (cls) => {
|
||||
return true
|
||||
}
|
||||
|
||||
const getClassStart = (cls) => {
|
||||
return new Date(`${cls.date}T${cls.time}`)
|
||||
}
|
||||
|
||||
const getClassEnd = (cls) => {
|
||||
const classStart = new Date(`${cls.date}T${cls.time}`)
|
||||
const classStart = getClassStart(cls)
|
||||
return new Date(classStart.getTime() + cls.duration * 60000)
|
||||
}
|
||||
|
||||
|
||||
@@ -76,15 +76,12 @@ const isModerator = ref(false)
|
||||
const isInstructor = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
sidebarSettings.reload(
|
||||
{},
|
||||
{
|
||||
onSuccess(data) {
|
||||
filterLinksToShow(data)
|
||||
addOtherLinks()
|
||||
},
|
||||
}
|
||||
)
|
||||
// Вызываем addSideBar только если userResource уже загружен
|
||||
if (userResource.data) {
|
||||
addSideBar()
|
||||
}
|
||||
addOtherLinks()
|
||||
filterLinksToShow(data)
|
||||
})
|
||||
|
||||
const handleOutsideClick = (e) => {
|
||||
@@ -113,24 +110,184 @@ const filterLinksToShow = (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
const addSideBar = () => {
|
||||
sidebarLinks.value = [] // Очищаем, чтобы избежать дублирования
|
||||
|
||||
// Проверяем роли пользователя
|
||||
const roles = userResource.data?.roles || []
|
||||
|
||||
sidebarLinks.value.push({
|
||||
label: __('Courses'),
|
||||
icon: 'BookOpen',
|
||||
to: 'Courses',
|
||||
activeFor: [
|
||||
'Courses',
|
||||
'CourseDetail',
|
||||
'Lesson',
|
||||
'CourseForm',
|
||||
'LessonForm',
|
||||
],
|
||||
})
|
||||
|
||||
sidebarLinks.value.push({
|
||||
label: __('Leader Board'),
|
||||
icon: 'Trophy',
|
||||
to: 'LeaderBoard',
|
||||
activeFor: [],
|
||||
})
|
||||
|
||||
if (roles.includes('LMS Student') || roles.includes('LMS Schoolchild')) {
|
||||
otherLinks.value.push({
|
||||
label: __('My points'),
|
||||
icon: 'Award',
|
||||
to: 'MyPoints',
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
|
||||
if (roles.includes('Parent')) {
|
||||
otherLinks.value.push({
|
||||
label: __('My Child'),
|
||||
icon: 'User',
|
||||
to: 'my-child',
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
|
||||
let chatGPTURL = ''
|
||||
let chatGPTLabel = ''
|
||||
|
||||
if (roles.includes('LMS Schoolchild')) {
|
||||
chatGPTURL = 'chatgpt-schoolchild'
|
||||
chatGPTLabel = __('ChatGPT for Schoolers')
|
||||
} else if (roles.includes('LMS Student')) {
|
||||
chatGPTURL = 'chatgpt-schoolchild'
|
||||
chatGPTLabel = __('ChatGPT for Students')
|
||||
} else if (roles.includes('Course Creator')) {
|
||||
chatGPTURL = 'ai-teachers'
|
||||
chatGPTLabel = __('ChatGPT for Teachers')
|
||||
}
|
||||
|
||||
if (chatGPTURL) {
|
||||
sidebarLinks.value.push({
|
||||
label: chatGPTLabel,
|
||||
icon: 'Cpu',
|
||||
to: chatGPTURL,
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
}
|
||||
const addOtherLinks = () => {
|
||||
otherLinks.value = []
|
||||
|
||||
if (user) {
|
||||
const roles = userResource.data?.roles || []
|
||||
|
||||
if (!userResource.data?.is_instructor && !userResource.data?.is_moderator) {
|
||||
otherLinks.value.push({
|
||||
label: __('Programs'),
|
||||
icon: 'Route',
|
||||
to: 'Programs',
|
||||
activeFor: ['Programs', 'ProgramForm', 'CourseDetail', 'Lesson'],
|
||||
})
|
||||
} else if (userResource.data?.is_instructor || userResource.data?.is_moderator) {
|
||||
otherLinks.value.push({
|
||||
label: __('Programs'),
|
||||
icon: 'Route',
|
||||
to: 'Programs',
|
||||
activeFor: ['Programs', 'ProgramForm'],
|
||||
})
|
||||
}
|
||||
|
||||
if (userResource.data?.is_moderator || userResource.data?.is_instructor) {
|
||||
otherLinks.value.push({
|
||||
label: __('Quizzes'),
|
||||
icon: 'CircleHelp',
|
||||
to: 'Quizzes',
|
||||
activeFor: [
|
||||
'Quizzes',
|
||||
'QuizForm',
|
||||
'QuizSubmissionList',
|
||||
'QuizSubmission',
|
||||
],
|
||||
})
|
||||
|
||||
otherLinks.value.push({
|
||||
label: __('Assignments'),
|
||||
icon: 'Pencil',
|
||||
to: 'Assignments',
|
||||
activeFor: [
|
||||
'Assignments',
|
||||
'AssignmentForm',
|
||||
'AssignmentSubmissionList',
|
||||
'AssignmentSubmission',
|
||||
],
|
||||
}),
|
||||
otherLinks.value.push({
|
||||
label: 'Programming Exercises',
|
||||
icon: 'Code',
|
||||
to: 'ProgrammingExercises',
|
||||
})
|
||||
}
|
||||
|
||||
if (roles.includes('LMS Student') || roles.includes('LMS Schoolchild')) {
|
||||
otherLinks.value.push({
|
||||
label: __('My points'),
|
||||
icon: 'Award',
|
||||
to: 'my_points',
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
|
||||
let chatGPTURL = ''
|
||||
let chatGPTLabel = ''
|
||||
|
||||
if (roles.includes('LMS Schoolchild')) {
|
||||
chatGPTURL = 'chatgpt-schoolchild'
|
||||
chatGPTLabel = __('ChatGPT for Schoolers')
|
||||
} else if (roles.includes('LMS Student')) {
|
||||
chatGPTURL = 'chatgpt-schoolchild'
|
||||
chatGPTLabel = __('ChatGPT for Students')
|
||||
} else if (roles.includes('Course Creator')) {
|
||||
chatGPTURL = 'ai-teachers'
|
||||
chatGPTLabel = __('ChatGPT for Teachers')
|
||||
}
|
||||
|
||||
if (chatGPTURL) {
|
||||
otherLinks.value.push({
|
||||
label: chatGPTLabel,
|
||||
icon: 'Cpu',
|
||||
to: chatGPTURL,
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
}
|
||||
|
||||
otherLinks.value.push({
|
||||
label: 'Notifications',
|
||||
icon: 'Bell',
|
||||
to: 'Notifications',
|
||||
label: __('Leader Board'),
|
||||
icon: 'Trophy',
|
||||
to: 'leaderboardsample',
|
||||
external: true,
|
||||
activeFor: [],
|
||||
})
|
||||
|
||||
otherLinks.value.push({
|
||||
label: 'Profile',
|
||||
label: __('Profile'),
|
||||
icon: 'UserRound',
|
||||
to: 'Profile',
|
||||
params: { username: userResource.data?.username },
|
||||
})
|
||||
|
||||
otherLinks.value.push({
|
||||
label: 'Log out',
|
||||
label: __('Log out'),
|
||||
icon: 'LogOut',
|
||||
})
|
||||
} else {
|
||||
otherLinks.value.push({
|
||||
label: 'Log in',
|
||||
label: __('Log in'),
|
||||
icon: 'LogIn',
|
||||
})
|
||||
}
|
||||
@@ -138,55 +295,11 @@ const addOtherLinks = () => {
|
||||
|
||||
watch(userResource, () => {
|
||||
if (userResource.data) {
|
||||
isModerator.value = userResource.data.is_moderator
|
||||
isInstructor.value = userResource.data.is_instructor
|
||||
addPrograms()
|
||||
if (isModerator.value || isInstructor.value) {
|
||||
addProgrammingExercises()
|
||||
addQuizzes()
|
||||
addAssignments()
|
||||
}
|
||||
addSideBar() // Обновляем sidebarLinks при изменении userResource
|
||||
addOtherLinks() // Обновляем otherLinks
|
||||
}
|
||||
})
|
||||
|
||||
const addQuizzes = () => {
|
||||
otherLinks.value.push({
|
||||
label: 'Quizzes',
|
||||
icon: 'CircleHelp',
|
||||
to: 'Quizzes',
|
||||
})
|
||||
}
|
||||
|
||||
const addAssignments = () => {
|
||||
otherLinks.value.push({
|
||||
label: 'Assignments',
|
||||
icon: 'Pencil',
|
||||
to: 'Assignments',
|
||||
})
|
||||
}
|
||||
|
||||
const addPrograms = async () => {
|
||||
let canAddProgram = await checkIfCanAddProgram()
|
||||
if (!canAddProgram) return
|
||||
let activeFor = ['Programs', 'ProgramDetail']
|
||||
let index = 1
|
||||
|
||||
sidebarLinks.value.splice(index, 0, {
|
||||
label: 'Programs',
|
||||
icon: 'Route',
|
||||
to: 'Programs',
|
||||
activeFor: activeFor,
|
||||
})
|
||||
}
|
||||
|
||||
const checkIfCanAddProgram = async () => {
|
||||
if (isModerator.value || isInstructor.value) {
|
||||
return true
|
||||
}
|
||||
const programs = await call('lms.lms.utils.get_programs')
|
||||
return programs.enrolled.length > 0 || programs.published.length > 0
|
||||
}
|
||||
|
||||
let isActive = (tab) => {
|
||||
return tab.activeFor?.includes(router.currentRoute.value.name)
|
||||
}
|
||||
@@ -204,6 +317,7 @@ const handleClick = (tab) => {
|
||||
username: userResource.data?.username,
|
||||
},
|
||||
})
|
||||
else if (tab.external) window.location.href = `/${tab.to}`
|
||||
else router.push({ name: tab.to })
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,14 @@ watch(
|
||||
{ flush: 'post' }
|
||||
)
|
||||
|
||||
watch(show, (newVal) => {
|
||||
if (newVal && props.assignmentID === 'new') {
|
||||
assignment.title = ''
|
||||
assignment.type = ''
|
||||
assignment.question = ''
|
||||
}
|
||||
})
|
||||
|
||||
const saveAssignment = () => {
|
||||
if (props.assignmentID == 'new') {
|
||||
assignments.value.insert.submit(
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<Avatar :image="student.user_image" size="3xl" />
|
||||
<div class="space-y-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="text-xl font-semibold">
|
||||
<div class="text-xl font-semibold text-ink-gray-9">
|
||||
{{ student.full_name }}
|
||||
</div>
|
||||
<Badge
|
||||
@@ -36,7 +36,9 @@
|
||||
v-if="Object.keys(student.assessments).length"
|
||||
class="space-y-2 text-sm"
|
||||
>
|
||||
<div class="flex items-center border-b pb-1 font-medium">
|
||||
<div
|
||||
class="flex items-center border-b pb-1 font-medium text-ink-gray-9"
|
||||
>
|
||||
<span class="flex-1">
|
||||
{{ __('Assessment') }}
|
||||
</span>
|
||||
@@ -86,7 +88,9 @@
|
||||
v-if="Object.keys(student.courses).length"
|
||||
class="space-y-2 text-sm"
|
||||
>
|
||||
<div class="flex items-center border-b pb-1 font-medium">
|
||||
<div
|
||||
class="flex items-center border-b pb-1 font-medium text-ink-gray-9"
|
||||
>
|
||||
<span class="flex-1">
|
||||
{{ __('Courses') }}
|
||||
</span>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<FileText class="h-5 w-5 stroke-1.5 text-ink-gray-7" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<span>
|
||||
<span class="text-ink-gray-9">
|
||||
{{ chapter.scorm_package.file_name }}
|
||||
</span>
|
||||
<span class="text-sm text-ink-gray-4 mt-1">
|
||||
|
||||
@@ -152,6 +152,7 @@ const show = defineModel<boolean>({ default: false })
|
||||
const searchFilter = ref<string | null>(null)
|
||||
type Filters = {
|
||||
course: string | undefined
|
||||
|
||||
member_name?: string[]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:options="{
|
||||
title: 'Edit your profile',
|
||||
title: __('Edit your profile'),
|
||||
size: '3xl',
|
||||
actions: [
|
||||
{
|
||||
label: 'Save',
|
||||
label: __('Save'),
|
||||
variant: 'solid',
|
||||
onClick: (close) => saveProfile(close),
|
||||
},
|
||||
|
||||
@@ -66,7 +66,11 @@
|
||||
</template>
|
||||
{{ __('View Certificate') }}
|
||||
</Button>
|
||||
<Button v-else @click="openCallLink(event.venue)" class="w-full">
|
||||
<Button
|
||||
v-else-if="userIsEvaluator()"
|
||||
@click="openCallLink(event.venue)"
|
||||
class="w-full"
|
||||
>
|
||||
<template #prefix>
|
||||
<Video class="h-4 w-4 stroke-1.5" />
|
||||
</template>
|
||||
@@ -83,21 +87,31 @@
|
||||
class="flex flex-col space-y-4 p-5"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<Rating v-model="evaluation.rating" :label="__('Rating')" />
|
||||
<Rating
|
||||
v-model="evaluation.rating"
|
||||
:label="__('Rating')"
|
||||
:disabled="!userIsEvaluator()"
|
||||
/>
|
||||
<FormControl
|
||||
type="select"
|
||||
:options="statusOptions"
|
||||
v-model="evaluation.status"
|
||||
:label="__('Status')"
|
||||
class="w-1/2"
|
||||
:disabled="!userIsEvaluator()"
|
||||
/>
|
||||
</div>
|
||||
<Textarea
|
||||
v-model="evaluation.summary"
|
||||
:label="__('Summary')"
|
||||
:rows="7"
|
||||
:disabled="!userIsEvaluator()"
|
||||
/>
|
||||
<Button variant="solid" @click="saveEvaluation()">
|
||||
<Button
|
||||
v-if="userIsEvaluator()"
|
||||
variant="solid"
|
||||
@click="saveEvaluation()"
|
||||
>
|
||||
{{ __('Save') }}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -106,11 +120,13 @@
|
||||
type="checkbox"
|
||||
v-model="certificate.published"
|
||||
:label="__('Published')"
|
||||
:disabled="!userIsEvaluator()"
|
||||
/>
|
||||
<Link
|
||||
v-model="certificate.template"
|
||||
:label="__('Template')"
|
||||
doctype="Print Format"
|
||||
:disabled="!userIsEvaluator()"
|
||||
:filters="{
|
||||
doc_type: 'LMS Certificate',
|
||||
}"
|
||||
@@ -118,14 +134,20 @@
|
||||
<FormControl
|
||||
type="date"
|
||||
v-model="certificate.issue_date"
|
||||
:disabled="!userIsEvaluator()"
|
||||
:label="__('Issue Date')"
|
||||
/>
|
||||
<FormControl
|
||||
type="date"
|
||||
v-model="certificate.expiry_date"
|
||||
:disabled="!userIsEvaluator()"
|
||||
:label="__('Expiry Date')"
|
||||
/>
|
||||
<Button variant="solid" @click="saveCertificate()">
|
||||
<Button
|
||||
v-if="userIsEvaluator()"
|
||||
variant="solid"
|
||||
@click="saveCertificate()"
|
||||
>
|
||||
{{ __('Save') }}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -163,6 +185,7 @@ import Rating from '@/components/Controls/Rating.vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
|
||||
const show = defineModel()
|
||||
const user = inject('$user')
|
||||
const dayjs = inject('$dayjs')
|
||||
const tabIndex = ref(0)
|
||||
const showCertification = ref(false)
|
||||
@@ -175,9 +198,18 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const evaluation = reactive({})
|
||||
|
||||
const certificate = reactive({})
|
||||
|
||||
watch(user, () => {
|
||||
if (userIsEvaluator()) {
|
||||
defaultTemplate.reload()
|
||||
}
|
||||
})
|
||||
|
||||
const userIsEvaluator = () => {
|
||||
return user.data && user.data.name == props.event.evaluator
|
||||
}
|
||||
|
||||
const defaultTemplate = createResource({
|
||||
url: 'frappe.client.get_value',
|
||||
makeParams(values) {
|
||||
@@ -190,7 +222,6 @@ const defaultTemplate = createResource({
|
||||
},
|
||||
}
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
certificate.template = data.value
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
>
|
||||
<template #body-content>
|
||||
<div class="flex flex-col gap-4">
|
||||
<p>
|
||||
<p class="text-ink-gray-9">
|
||||
{{
|
||||
__(
|
||||
'Submit your resume to proceed with your application for this position. Upon submission, it will be shared with the job poster.'
|
||||
@@ -51,7 +51,7 @@
|
||||
<FileText class="h-5 w-5 stroke-1.5 text-ink-gray-7" />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<span>
|
||||
<span class="text-ink-gray-9">
|
||||
{{ resume.file_name }}
|
||||
</span>
|
||||
<span class="text-sm text-ink-gray-4 mt-1">
|
||||
|
||||
@@ -126,7 +126,7 @@ import {
|
||||
Button,
|
||||
toast,
|
||||
} from 'frappe-ui'
|
||||
import { computed, watch, reactive, ref, inject } from 'vue'
|
||||
import { watch, reactive, ref, inject } from 'vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import { useOnboarding } from 'frappe-ui/frappe'
|
||||
|
||||
@@ -141,6 +141,7 @@ const existingQuestion = reactive({
|
||||
question: '',
|
||||
marks: 1,
|
||||
})
|
||||
|
||||
const question = reactive({
|
||||
question: '',
|
||||
type: 'Choices',
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<div class="border rounded-md w-1/3 mx-auto my-32">
|
||||
<div class="border-b px-5 py-3 font-medium">
|
||||
<div class="border-b px-5 py-3 font-medium text-ink-gray-9">
|
||||
<span
|
||||
class="inline-flex items-center before:bg-surface-red-5 before:w-2 before:h-2 before:rounded-md before:mr-2"
|
||||
></span>
|
||||
{{ __('Not Permitted') }}
|
||||
</div>
|
||||
<div v-if="user.data" class="px-5 py-3">
|
||||
<div>
|
||||
<div class="text-ink-gray-7">
|
||||
{{ __('You do not have permission to access this page.') }}
|
||||
</div>
|
||||
<router-link
|
||||
@@ -21,7 +21,7 @@
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="px-5 py-3">
|
||||
<div>
|
||||
<div class="text-ink-gray-7">
|
||||
{{ __('Please login to access this page.') }}
|
||||
</div>
|
||||
<Button @click="redirectToLogin()" class="mt-4">
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<div class="text-base border rounded-md w-1/3 mx-auto my-32">
|
||||
<div class="border-b px-5 py-3 font-medium">
|
||||
<div class="border-b px-5 py-3 font-medium text-ink-gray-9">
|
||||
<span
|
||||
class="inline-flex items-center before:bg-surface-red-5 before:w-2 before:h-2 before:rounded-md before:mr-2"
|
||||
></span>
|
||||
{{ __(title) }}
|
||||
</div>
|
||||
<div class="px-5 py-3">
|
||||
<div class="mb-4 leading-6">
|
||||
<div class="mb-4 leading-6 text-ink-gray-7">
|
||||
{{ __(text) }}
|
||||
</div>
|
||||
<Button variant="solid" class="w-full" @click="redirect()">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="text-lg font-semibold mb-4">
|
||||
<div class="text-lg font-semibold mb-4 text-ink-gray-9">
|
||||
{{ __('My Notes') }}
|
||||
</div>
|
||||
<TextEditor
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
|
||||
<div v-if="quiz.data.duration" class="flex flex-col space-x-1 my-4">
|
||||
<div class="mb-2">
|
||||
<span class=""> {{ __('Time') }}: </span>
|
||||
<span class="font-semibold">
|
||||
<span class="text-ink-gray-9"> {{ __('Time') }}: </span>
|
||||
<span class="font-semibold text-ink-gray-9">
|
||||
{{ formatTimer(timer) }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -165,14 +165,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
class="ml-2"
|
||||
class="ml-2 text-ink-gray-9"
|
||||
v-html="questionDetails.data[`option_${index}`]"
|
||||
>
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
v-if="questionDetails.data[`explanation_${index}`]"
|
||||
class="mt-2 text-xs"
|
||||
class="mt-2 text-xs text-ink-gray-7"
|
||||
v-show="showAnswers.length"
|
||||
>
|
||||
{{ questionDetails.data[`explanation_${index}`] }}
|
||||
@@ -260,7 +260,7 @@
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-else class="text-ink-gray-7">
|
||||
{{
|
||||
__(
|
||||
'You got {0}% correct answers with a score of {1} out of {2}'
|
||||
|
||||
@@ -69,9 +69,12 @@ const update = () => {
|
||||
let imageFields = ['favicon', 'banner_image']
|
||||
props.fields.forEach((f) => {
|
||||
if (imageFields.includes(f.name)) {
|
||||
fieldsToSave[f.name] = f.value ? f.value.file_url : null
|
||||
fieldsToSave[f.name] =
|
||||
branding.data[f.name] && branding.data[f.name].file_url
|
||||
? branding.data[f.name].file_url
|
||||
: null
|
||||
} else {
|
||||
fieldsToSave[f.name] = f.value
|
||||
fieldsToSave[f.name] = branding.data[f.name]
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -141,9 +141,6 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
},
|
||||
})
|
||||
|
||||
const evaluators = createListResource({
|
||||
|
||||
@@ -156,9 +156,6 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
},
|
||||
})
|
||||
|
||||
const members = createResource({
|
||||
@@ -185,7 +182,6 @@ const openProfile = (username: string) => {
|
||||
username: username,
|
||||
},
|
||||
})
|
||||
console.log(show.value)
|
||||
}
|
||||
|
||||
const newMember = createResource({
|
||||
|
||||
233
frontend/src/components/Settings/PaymentGatewayDetails.vue
Normal file
233
frontend/src/components/Settings/PaymentGatewayDetails.vue
Normal file
@@ -0,0 +1,233 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
title:
|
||||
gatewayID === 'new'
|
||||
? __('New Payment Gateway')
|
||||
: __('Edit Payment Gateway'),
|
||||
size: '3xl',
|
||||
}"
|
||||
>
|
||||
<template #body-content>
|
||||
<SettingFields
|
||||
v-if="gatewayID != 'new' && paymentGateway.data"
|
||||
:fields="paymentGateway.data.fields"
|
||||
:data="paymentGateway.data.data"
|
||||
class="pt-5 my-0"
|
||||
/>
|
||||
<div v-else>
|
||||
<FormControl
|
||||
v-model="newGateway"
|
||||
:label="__('Select Payment Gateway')"
|
||||
type="select"
|
||||
:options="allGatewayOptions"
|
||||
:required="true"
|
||||
/>
|
||||
<SettingFields
|
||||
v-if="newGateway"
|
||||
:fields="newGatewayFields"
|
||||
:data="newGatewayData"
|
||||
class="pt-5 my-0"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions="{ close }">
|
||||
<div class="pb-5 float-right">
|
||||
<Button variant="solid" @click="saveSettings(close)">
|
||||
{{ __('Save') }}
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
call,
|
||||
createListResource,
|
||||
createResource,
|
||||
Dialog,
|
||||
FormControl,
|
||||
} from 'frappe-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import SettingFields from '@/components/Settings/SettingFields.vue'
|
||||
|
||||
const show = defineModel<boolean>({ required: true, default: false })
|
||||
const paymentGateways = defineModel<any>('paymentGateways')
|
||||
const newGateway = ref(null)
|
||||
const newGatewayFields = ref([])
|
||||
const newGatewayData = ref<Record<string, any>>({})
|
||||
|
||||
const props = defineProps<{
|
||||
gatewayID: string | null
|
||||
}>()
|
||||
|
||||
const paymentGateway = createResource({
|
||||
url: 'lms.lms.api.get_payment_gateway_details',
|
||||
makeParams(values: any) {
|
||||
return {
|
||||
payment_gateway: props.gatewayID,
|
||||
}
|
||||
},
|
||||
transform(data: any) {
|
||||
arrangeFields(data.fields)
|
||||
return data
|
||||
},
|
||||
})
|
||||
|
||||
const allGateways = createListResource({
|
||||
doctype: 'DocType',
|
||||
filters: {
|
||||
module: 'Payment Gateways',
|
||||
},
|
||||
fields: ['name', 'issingle'],
|
||||
})
|
||||
|
||||
const gatewayFields = createResource({
|
||||
url: 'lms.lms.api.get_new_gateway_fields',
|
||||
makeParams(values: any) {
|
||||
return {
|
||||
doctype: values.doctype,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const arrangeFields = (fields: any[]) => {
|
||||
fields = fields.sort((a, b) => {
|
||||
if (a.type === 'Upload' && b.type !== 'Upload') {
|
||||
return 1
|
||||
} else if (a.type !== 'Upload' && b.type === 'Upload') {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
fields.splice(3, 0, {
|
||||
type: 'Column Break',
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.gatewayID,
|
||||
() => {
|
||||
if (props.gatewayID && props.gatewayID !== 'new') {
|
||||
paymentGateway.reload()
|
||||
} else if (props.gatewayID == 'new') {
|
||||
allGateways.reload()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const getNewGateway = () => {
|
||||
return allGateways.data?.find((gateway: any) =>
|
||||
gateway.name.includes(newGateway.value)
|
||||
)
|
||||
}
|
||||
|
||||
watch(newGateway, () => {
|
||||
let gatewayDoc = getNewGateway()
|
||||
gatewayFields.reload({ doctype: gatewayDoc.name }).then(() => {
|
||||
let fields = gatewayFields.data || []
|
||||
arrangeFields(fields)
|
||||
newGatewayFields.value = fields
|
||||
prepareGatewayData()
|
||||
})
|
||||
})
|
||||
|
||||
const saveSettings = (close: () => void) => {
|
||||
if (props.gatewayID === 'new') {
|
||||
saveNewGateway(close)
|
||||
} else {
|
||||
saveExistingGateway(
|
||||
paymentGateway.data.doctype,
|
||||
paymentGateway.data.docname,
|
||||
close
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const saveNewGateway = (close: () => void) => {
|
||||
let gatewayDoc = getNewGateway()
|
||||
if (gatewayDoc.issingle) {
|
||||
saveExistingGateway(gatewayDoc.name, gatewayDoc.name, close)
|
||||
} else {
|
||||
call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: gatewayDoc.name,
|
||||
...newGatewayData.value,
|
||||
},
|
||||
}).then((data: any) => {
|
||||
paymentGateways.value.reload()
|
||||
close()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const saveExistingGateway = (
|
||||
doctype: string,
|
||||
docname: string,
|
||||
close: () => void
|
||||
) => {
|
||||
call('frappe.client.set_value', {
|
||||
doctype: doctype,
|
||||
name: docname,
|
||||
fieldname: getGatewayFields(),
|
||||
}).then(() => {
|
||||
paymentGateways.value?.reload()
|
||||
close()
|
||||
})
|
||||
}
|
||||
|
||||
const getGatewayFields = () => {
|
||||
let data =
|
||||
props.gatewayID == 'new' ? newGatewayData.value : paymentGateway.data.data
|
||||
return Object.keys(data).reduce((fields: any, key: string) => {
|
||||
if (data[key] && typeof data[key] === 'object') {
|
||||
fields[key] = data[key].file_url
|
||||
} else {
|
||||
fields[key] = data[key]
|
||||
}
|
||||
return fields
|
||||
}, {})
|
||||
}
|
||||
|
||||
const createGatewayRecord = (gatewayDoc: any, data: any = {}) => {
|
||||
call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'Payment Gateway',
|
||||
gateway: newGateway.value,
|
||||
gateway_controller: gatewayDoc.issingle ? '' : gatewayDoc.name,
|
||||
gateway_settings: gatewayDoc.issingle ? '' : data.name,
|
||||
},
|
||||
}).then(() => {
|
||||
paymentGateways.value?.reload()
|
||||
})
|
||||
}
|
||||
|
||||
const allGatewayOptions = computed(() => {
|
||||
let options: string[] = []
|
||||
let gatewayList = allGateways.data?.map((gateway: any) => gateway.name) || []
|
||||
gatewayList.forEach((gateway: any) => {
|
||||
let gatewayName = gateway.split(' ')[0]
|
||||
let existingGateways =
|
||||
paymentGateways.value?.data?.map((pg: any) => pg.name) || []
|
||||
if (
|
||||
!options.includes(gatewayName) &&
|
||||
!existingGateways.includes(gatewayName)
|
||||
) {
|
||||
options.push(gatewayName)
|
||||
}
|
||||
})
|
||||
return options.map((gateway: string) => ({ label: gateway, value: gateway }))
|
||||
})
|
||||
|
||||
const prepareGatewayData = () => {
|
||||
newGatewayData.value = {}
|
||||
if (newGatewayFields.value.length) {
|
||||
newGatewayFields.value.forEach((field: any) => {
|
||||
newGatewayData.value[field.fieldname] = field.default || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
140
frontend/src/components/Settings/PaymentGateways.vue
Normal file
140
frontend/src/components/Settings/PaymentGateways.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="flex min-h-0 flex-col text-base">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
<div>
|
||||
<div class="text-xl font-semibold mb-1 text-ink-gray-9">
|
||||
{{ __(label) }}
|
||||
</div>
|
||||
<div class="text-ink-gray-6 leading-5">
|
||||
{{ __(description) }}
|
||||
</div>
|
||||
</div>
|
||||
<Button @click="openForm('new')">
|
||||
<template #prefix>
|
||||
<Plus class="h-3 w-3 stroke-1.5" />
|
||||
</template>
|
||||
{{ __('New') }}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div v-if="paymentGateways.data?.length" class="overflow-y-scroll">
|
||||
<ListView
|
||||
:columns="columns"
|
||||
:rows="paymentGateways.data"
|
||||
row-key="name"
|
||||
:options="{
|
||||
showTooltip: false,
|
||||
onRowClick: (row) => {
|
||||
openForm(row.name)
|
||||
},
|
||||
}"
|
||||
>
|
||||
<ListHeader
|
||||
class="mb-2 grid items-center space-x-4 rounded bg-surface-gray-2 p-2"
|
||||
>
|
||||
<ListHeaderItem :item="item" v-for="item in columns">
|
||||
<template #prefix="{ item }">
|
||||
<FeatherIcon
|
||||
v-if="item.icon"
|
||||
:name="item.icon"
|
||||
class="h-4 w-4 stroke-1.5"
|
||||
/>
|
||||
</template>
|
||||
</ListHeaderItem>
|
||||
</ListHeader>
|
||||
|
||||
<ListRows>
|
||||
<ListRow :row="row" v-for="row in paymentGateways.data">
|
||||
<template #default="{ column, item }">
|
||||
<ListRowItem :item="row[column.key]" :align="column.align">
|
||||
<div v-if="column.key == 'enabled'">
|
||||
<Badge v-if="row[column.key]" theme="green">
|
||||
{{ __('Enabled') }}
|
||||
</Badge>
|
||||
<Badge v-else theme="gray">
|
||||
{{ __('Disabled') }}
|
||||
</Badge>
|
||||
</div>
|
||||
<div v-else class="leading-5 text-sm">
|
||||
{{ row[column.key] }}
|
||||
</div>
|
||||
</ListRowItem>
|
||||
</template>
|
||||
</ListRow>
|
||||
</ListRows>
|
||||
|
||||
<ListSelectBanner>
|
||||
<template #actions="{ unselectAll, selections }">
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
@click="removeAccount(selections, unselectAll)"
|
||||
>
|
||||
<Trash2 class="h-4 w-4 stroke-1.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</ListSelectBanner>
|
||||
</ListView>
|
||||
</div>
|
||||
</div>
|
||||
<PaymentGatewayDetails
|
||||
v-model="showForm"
|
||||
:gatewayID="currentGateway"
|
||||
v-model:paymentGateways="paymentGateways"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
createListResource,
|
||||
FeatherIcon,
|
||||
ListView,
|
||||
ListHeader,
|
||||
ListHeaderItem,
|
||||
ListRows,
|
||||
ListRow,
|
||||
ListRowItem,
|
||||
ListSelectBanner,
|
||||
} from 'frappe-ui'
|
||||
import { computed, ref } from 'vue'
|
||||
import { Plus, Trash2 } from 'lucide-vue-next'
|
||||
import PaymentGatewayDetails from '@/components/Settings/PaymentGatewayDetails.vue'
|
||||
|
||||
const showForm = ref(false)
|
||||
const currentGateway = ref(null)
|
||||
|
||||
const props = defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const paymentGateways = createListResource({
|
||||
doctype: 'Payment Gateway',
|
||||
fields: ['name', 'gateway_settings', 'gateway_controller'],
|
||||
auto: true,
|
||||
orderBy: 'modified desc',
|
||||
})
|
||||
|
||||
const openForm = (gatewayID) => {
|
||||
currentGateway.value = gatewayID
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
const columns = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: __('Gateway'),
|
||||
key: 'name',
|
||||
icon: 'credit-card',
|
||||
},
|
||||
]
|
||||
})
|
||||
</script>
|
||||
@@ -1,128 +0,0 @@
|
||||
<template>
|
||||
<div class="flex flex-col h-full">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="text-xl font-semibold mb-1 text-ink-gray-9">
|
||||
{{ label }}
|
||||
</div>
|
||||
<!-- <Badge
|
||||
v-if="isDirty"
|
||||
:label="__('Not Saved')"
|
||||
variant="subtle"
|
||||
theme="orange"
|
||||
/> -->
|
||||
</div>
|
||||
<div class="overflow-y-scroll">
|
||||
<div class="flex flex-col divide-y">
|
||||
<SettingFields :fields="fields" :data="data.doc" />
|
||||
<SettingFields
|
||||
v-if="paymentGateway.data"
|
||||
:fields="paymentGateway.data.fields"
|
||||
:data="paymentGateway.data.data"
|
||||
class="pt-5 my-0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row-reverse mt-auto">
|
||||
<Button variant="solid" @click="update">
|
||||
{{ __('Update') }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import SettingFields from '@/components/Settings/SettingFields.vue'
|
||||
import { createResource, Badge, Button } from 'frappe-ui'
|
||||
import { watch } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
fields: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const paymentGateway = createResource({
|
||||
url: 'lms.lms.api.get_payment_gateway_details',
|
||||
makeParams(values) {
|
||||
return {
|
||||
payment_gateway: props.data.doc.payment_gateway,
|
||||
}
|
||||
},
|
||||
transform(data) {
|
||||
arrangeFields(data.fields)
|
||||
return data
|
||||
},
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const arrangeFields = (fields) => {
|
||||
fields = fields.sort((a, b) => {
|
||||
if (a.type === 'Upload' && b.type !== 'Upload') {
|
||||
return 1
|
||||
} else if (a.type !== 'Upload' && b.type === 'Upload') {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
fields.splice(3, 0, {
|
||||
type: 'Column Break',
|
||||
})
|
||||
}
|
||||
|
||||
const saveSettings = createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
makeParams(values) {
|
||||
let fields = {}
|
||||
Object.keys(paymentGateway.data.data).forEach((key) => {
|
||||
if (
|
||||
paymentGateway.data.data[key] &&
|
||||
typeof paymentGateway.data.data[key] === 'object'
|
||||
) {
|
||||
fields[key] = paymentGateway.data.data[key].file_url
|
||||
} else {
|
||||
fields[key] = paymentGateway.data.data[key]
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
doctype: paymentGateway.data.doctype,
|
||||
name: paymentGateway.data.docname,
|
||||
fieldname: fields,
|
||||
}
|
||||
},
|
||||
auto: false,
|
||||
onSuccess(data) {
|
||||
paymentGateway.reload()
|
||||
},
|
||||
})
|
||||
|
||||
const update = () => {
|
||||
props.fields.forEach((f) => {
|
||||
if (f.type != 'Column Break') {
|
||||
props.data.doc[f.name] = f.value
|
||||
}
|
||||
})
|
||||
props.data.save.submit()
|
||||
saveSettings.submit()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.data.doc.payment_gateway,
|
||||
() => {
|
||||
paymentGateway.reload()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="flex flex-col justify-between h-full">
|
||||
<div class="flex flex-col justify-between h-full text-base">
|
||||
<div>
|
||||
<div class="flex itemsc-center justify-between">
|
||||
<div class="text-xl font-semibold leading-none mb-1 text-ink-gray-9">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="text-xl font-semibold leading-none mb-2 text-ink-gray-9">
|
||||
{{ __(label) }}
|
||||
</div>
|
||||
<Badge
|
||||
@@ -12,7 +12,7 @@
|
||||
theme="orange"
|
||||
/>
|
||||
</div>
|
||||
<div class="text-xs text-ink-gray-5">
|
||||
<div class="text-ink-gray-6 leading-5">
|
||||
{{ __(description) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,12 +30,9 @@
|
||||
</CodeEditor>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="field.type == 'Upload'"
|
||||
class="grid grid-cols-2 gap-10"
|
||||
>
|
||||
<div class="space-y-2">
|
||||
<div class="text-sm text-ink-gray-8 font-medium mb-1">
|
||||
<div v-else-if="field.type == 'Upload'">
|
||||
<div class="space-y-1 mb-2">
|
||||
<div class="text-sm text-ink-gray-5 font-medium">
|
||||
{{ __(field.label) }}
|
||||
</div>
|
||||
<div class="text-sm text-ink-gray-5 leading-5">
|
||||
@@ -99,7 +96,7 @@
|
||||
size="sm"
|
||||
:label="__(field.label)"
|
||||
:description="__(field.description)"
|
||||
v-model="data[field.name]"
|
||||
v-model="field.value"
|
||||
/>
|
||||
|
||||
<FormControl
|
||||
@@ -150,8 +147,6 @@ const columns = computed(() => {
|
||||
} else {
|
||||
if (field.type == 'checkbox') {
|
||||
field.value = props.data[field.name] ? true : false
|
||||
} else {
|
||||
field.value = props.data[field.name]
|
||||
}
|
||||
currentColumn.push(field)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
<Dialog v-model="show" :options="{ size: '5xl' }">
|
||||
<template #body>
|
||||
<div class="flex h-[calc(100vh_-_8rem)]">
|
||||
<div class="flex w-52 shrink-0 flex-col bg-surface-gray-2 p-2">
|
||||
<div
|
||||
class="flex w-52 shrink-0 flex-col bg-surface-gray-2 p-2 overflow-y-auto"
|
||||
>
|
||||
<h1 class="mb-3 px-2 pt-2 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Settings') }}
|
||||
</h1>
|
||||
@@ -14,18 +16,13 @@
|
||||
<span>{{ __(tab.label) }}</span>
|
||||
</div>
|
||||
<nav class="space-y-1">
|
||||
<SidebarLink
|
||||
v-for="item in tab.items"
|
||||
:link="item"
|
||||
:key="item.label"
|
||||
class="w-full"
|
||||
:class="
|
||||
activeTab?.label == item.label
|
||||
? 'bg-surface-selected shadow-sm'
|
||||
: 'hover:bg-surface-gray-2'
|
||||
"
|
||||
@click="activeTab = item"
|
||||
/>
|
||||
<div v-for="item in tab.items" @click="activeTab = item">
|
||||
<SidebarLink
|
||||
:link="item"
|
||||
:key="item.label"
|
||||
:activeTab="activeTab?.label"
|
||||
/>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,22 +34,26 @@
|
||||
<component
|
||||
v-if="activeTab.template"
|
||||
:is="activeTab.template"
|
||||
v-model:show="show"
|
||||
v-bind="{
|
||||
label: activeTab.label,
|
||||
description: activeTab.description,
|
||||
...(activeTab.label === 'Branding'
|
||||
...(activeTab.label == 'Branding'
|
||||
? { fields: activeTab.fields }
|
||||
: {}),
|
||||
...(activeTab.label == 'Evaluators' ||
|
||||
activeTab.label == 'Members' ||
|
||||
activeTab.label == 'Transactions'
|
||||
? { 'onUpdate:show': (val) => (show = val), show }
|
||||
: {}),
|
||||
}"
|
||||
/>
|
||||
<PaymentSettings
|
||||
v-else-if="activeTab.label === 'Payment Gateway'"
|
||||
<!-- <PaymentSettings
|
||||
v-else-if="activeTab.label === 'Gateways'"
|
||||
:label="activeTab.label"
|
||||
:description="activeTab.description"
|
||||
:data="data"
|
||||
:fields="activeTab.fields"
|
||||
/>
|
||||
/> -->
|
||||
<SettingDetails
|
||||
v-else
|
||||
:fields="activeTab.fields"
|
||||
@@ -76,7 +77,8 @@ import Evaluators from '@/components/Settings/Evaluators.vue'
|
||||
import Categories from '@/components/Settings/Categories.vue'
|
||||
import EmailTemplates from '@/components/Settings/EmailTemplates.vue'
|
||||
import BrandSettings from '@/components/Settings/BrandSettings.vue'
|
||||
import PaymentSettings from '@/components/Settings/PaymentSettings.vue'
|
||||
import PaymentGateways from '@/components/Settings/PaymentGateways.vue'
|
||||
import Transactions from '@/components/Settings/Transactions.vue'
|
||||
import ZoomSettings from '@/components/Settings/ZoomSettings.vue'
|
||||
import Badges from '@/components/Settings/Badges.vue'
|
||||
|
||||
@@ -156,17 +158,36 @@ const tabsStructure = computed(() => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Contact Us',
|
||||
icon: 'Phone',
|
||||
fields: [
|
||||
{
|
||||
label: 'Email',
|
||||
name: 'contact_us_email',
|
||||
type: 'text',
|
||||
description:
|
||||
'Users can reach out to this email for support or inquiries.',
|
||||
},
|
||||
{
|
||||
label: 'URL',
|
||||
name: 'contact_us_url',
|
||||
type: 'text',
|
||||
description:
|
||||
'Users can reach out to this URL for support or inquiries.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Settings',
|
||||
hideLabel: true,
|
||||
label: 'Payment',
|
||||
hideLabel: false,
|
||||
items: [
|
||||
{
|
||||
label: 'Payment Gateway',
|
||||
icon: 'DollarSign',
|
||||
description:
|
||||
'Configure the payment gateway and other payment related settings',
|
||||
label: 'Configuration',
|
||||
icon: 'CreditCard',
|
||||
description: 'Manage all your payment related settings and defaults',
|
||||
fields: [
|
||||
{
|
||||
label: 'Default Currency',
|
||||
@@ -200,6 +221,18 @@ const tabsStructure = computed(() => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Gateways',
|
||||
icon: 'DollarSign',
|
||||
template: markRaw(PaymentGateways),
|
||||
description: 'Add and manage all your payment gateways',
|
||||
},
|
||||
{
|
||||
label: 'Transactions',
|
||||
icon: 'Landmark',
|
||||
template: markRaw(Transactions),
|
||||
description: 'View all your payment transactions',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -275,7 +308,7 @@ const tabsStructure = computed(() => {
|
||||
name: 'favicon',
|
||||
type: 'Upload',
|
||||
description:
|
||||
'Appears in the browser tab next to the page title, bookmarks, and shortcuts to help users quickly identify the application.',
|
||||
'Appears in the browser tab next to the page title to help users quickly identify the application.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -300,8 +333,8 @@ const tabsStructure = computed(() => {
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
label: 'Certified Members',
|
||||
name: 'certified_members',
|
||||
label: 'Certifications',
|
||||
name: 'certifications',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
|
||||
152
frontend/src/components/Settings/TransactionDetails.vue
Normal file
152
frontend/src/components/Settings/TransactionDetails.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
title: __('Transaction Details'),
|
||||
size: '3xl',
|
||||
}"
|
||||
>
|
||||
<template #body-content>
|
||||
<div v-if="transactionData" class="text-base">
|
||||
<div class="grid grid-cols-3 gap-5 mt-5">
|
||||
<FormControl
|
||||
:label="__('Payment Received')"
|
||||
type="checkbox"
|
||||
v-model="transactionData.payment_received"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Payment For Certificate')"
|
||||
type="checkbox"
|
||||
v-model="transactionData.payment_for_certificate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-5 mt-5">
|
||||
<Link
|
||||
:label="__('Member')"
|
||||
doctype="User"
|
||||
v-model="transactionData.member"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Billing Name')"
|
||||
v-model="transactionData.billing_name"
|
||||
/>
|
||||
<Link
|
||||
:label="__('Source')"
|
||||
v-model="transactionData.source"
|
||||
doctype="LMS Source"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="font-semibold mt-10">
|
||||
{{ __('Payment Details') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-5 mt-5">
|
||||
<Link
|
||||
:label="__('Payment For Document Type')"
|
||||
v-model="transactionData.payment_for_document_type"
|
||||
doctype="DocType"
|
||||
/>
|
||||
<Link
|
||||
:label="__('Payment For Document')"
|
||||
v-model="transactionData.payment_for_document"
|
||||
:doctype="transactionData.payment_for_document_type"
|
||||
/>
|
||||
<Link
|
||||
:label="__('Address')"
|
||||
v-model="transactionData.address"
|
||||
doctype="Address"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-5 mt-5">
|
||||
<Link
|
||||
:label="__('Currency')"
|
||||
v-model="transactionData.currency"
|
||||
doctype="Currency"
|
||||
/>
|
||||
<FormControl :label="__('Amount')" v-model="transactionData.amount" />
|
||||
<FormControl
|
||||
:label="__('Order ID')"
|
||||
v-model="transactionData.order_id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-5 mt-5">
|
||||
<FormControl :label="__('GSTIN')" v-model="transactionData.gstin" />
|
||||
<FormControl :label="__('PAN')" v-model="transactionData.pan" />
|
||||
<FormControl
|
||||
:label="__('Payment ID')"
|
||||
v-model="transactionData.payment_id"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions="{ close }">
|
||||
<div class="space-x-2 pb-5 float-right">
|
||||
<Button @click="openDetails(close)">
|
||||
{{ __('Open the ') }}
|
||||
{{
|
||||
transaction.payment_for_document_type == 'LMS Course'
|
||||
? __('Course')
|
||||
: __('Batch')
|
||||
}}
|
||||
</Button>
|
||||
<Button variant="solid" @click="saveTransaction(close)">
|
||||
{{ __('Save') }}
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Dialog, FormControl, Button } from 'frappe-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref, watch } from 'vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
|
||||
const show = defineModel<boolean>({ required: true, default: false })
|
||||
const transactions = defineModel<any>('transactions')
|
||||
const router = useRouter()
|
||||
const showModal = defineModel('show')
|
||||
const transactionData = ref<{ [key: string]: any } | null>(null)
|
||||
|
||||
const props = defineProps<{
|
||||
transaction: { [key: string]: any } | null
|
||||
}>()
|
||||
|
||||
watch(
|
||||
() => props.transaction,
|
||||
(newVal) => {
|
||||
transactionData.value = newVal ? { ...newVal } : null
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const saveTransaction = (close: () => void) => {
|
||||
transactions.value.setValue
|
||||
.submit({
|
||||
...transactionData.value,
|
||||
})
|
||||
.then(() => {
|
||||
close()
|
||||
})
|
||||
}
|
||||
|
||||
const openDetails = (close: Function) => {
|
||||
if (props.transaction) {
|
||||
const docType = props.transaction.payment_for_document_type
|
||||
const docName = props.transaction.payment_for_document
|
||||
if (docType && docName) {
|
||||
router.push({
|
||||
name: docType == 'LMS Course' ? 'CourseDetail' : 'BatchDetail',
|
||||
params: {
|
||||
[docType == 'LMS Course' ? 'courseName' : 'batchName']: docName,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
close()
|
||||
showModal.value = false
|
||||
}
|
||||
</script>
|
||||
241
frontend/src/components/Settings/Transactions.vue
Normal file
241
frontend/src/components/Settings/Transactions.vue
Normal file
@@ -0,0 +1,241 @@
|
||||
<template>
|
||||
<div class="flex min-h-0 flex-col text-base">
|
||||
<div class="mb-5">
|
||||
<div class="text-xl font-semibold mb-1 text-ink-gray-9">
|
||||
{{ __(label) }}
|
||||
</div>
|
||||
<div class="text-ink-gray-6 leading-5">
|
||||
{{ __(description) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-5 mb-4">
|
||||
<FormControl
|
||||
v-model="billingName"
|
||||
:placeholder="__('Filter by Billing Name')"
|
||||
/>
|
||||
<Link
|
||||
v-model="member"
|
||||
doctype="User"
|
||||
:placeholder="__('Filter by Member')"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="paymentReceived"
|
||||
type="checkbox"
|
||||
:label="__('Payment Received')"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="paymentForCertificate"
|
||||
type="checkbox"
|
||||
:label="__('Payment for Certificate')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="transactions.data?.length" class="overflow-y-scroll">
|
||||
<ListView
|
||||
:columns="columns"
|
||||
:rows="transactions.data"
|
||||
row-key="name"
|
||||
:options="{
|
||||
showTooltip: false,
|
||||
selectable: false,
|
||||
onRowClick: (row: { [key: string]: any }) => {
|
||||
openForm(row)
|
||||
},
|
||||
}"
|
||||
>
|
||||
<ListHeader
|
||||
class="mb-2 grid items-center space-x-4 rounded bg-surface-gray-2 p-2"
|
||||
>
|
||||
<ListHeaderItem :item="item" v-for="item in columns">
|
||||
<template #prefix="{ item }">
|
||||
<FeatherIcon
|
||||
v-if="item.icon"
|
||||
:name="item.icon"
|
||||
class="h-4 w-4 stroke-1.5"
|
||||
/>
|
||||
</template>
|
||||
</ListHeaderItem>
|
||||
</ListHeader>
|
||||
|
||||
<ListRows>
|
||||
<ListRow :row="row" v-for="row in transactions.data">
|
||||
<template #default="{ column, item }">
|
||||
<ListRowItem :item="row[column.key]" :align="column.align">
|
||||
<FormControl
|
||||
v-if="
|
||||
['payment_received', 'payment_for_certificate'].includes(
|
||||
column.key
|
||||
)
|
||||
"
|
||||
type="checkbox"
|
||||
v-model="row[column.key]"
|
||||
:disabled="true"
|
||||
/>
|
||||
<div v-else-if="column.key == 'amount'">
|
||||
{{ getCurrencySymbol(row['currency']) }} {{ row[column.key] }}
|
||||
</div>
|
||||
<div v-else class="leading-5 text-sm">
|
||||
{{ row[column.key] }}
|
||||
</div>
|
||||
</ListRowItem>
|
||||
</template>
|
||||
</ListRow>
|
||||
</ListRows>
|
||||
</ListView>
|
||||
<div
|
||||
v-if="transactions.data.length && transactions.hasNextPage"
|
||||
class="flex justify-center mt-4"
|
||||
>
|
||||
<Button @click="transactions.next()">
|
||||
<template #prefix>
|
||||
<RefreshCw class="h-3 w-3 stroke-1.5" />
|
||||
</template>
|
||||
{{ __('Load More') }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<TransactionDetails
|
||||
v-model="showForm"
|
||||
:transaction="currentTransaction"
|
||||
v-model:transactions="transactions"
|
||||
v-model:show="show"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
createListResource,
|
||||
ListView,
|
||||
ListHeader,
|
||||
ListHeaderItem,
|
||||
FeatherIcon,
|
||||
ListRows,
|
||||
ListRow,
|
||||
ListRowItem,
|
||||
FormControl,
|
||||
} from 'frappe-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { RefreshCw } from 'lucide-vue-next'
|
||||
import TransactionDetails from './TransactionDetails.vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
|
||||
const showForm = ref(false)
|
||||
const currentTransaction = ref<{ [key: string]: any } | null>(null)
|
||||
const show = defineModel('show')
|
||||
const billingName = ref(null)
|
||||
const paymentReceived = ref(false)
|
||||
const paymentForCertificate = ref(false)
|
||||
const member = ref(null)
|
||||
|
||||
const props = defineProps({
|
||||
label: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const transactions = createListResource({
|
||||
doctype: 'LMS Payment',
|
||||
fields: [
|
||||
'name',
|
||||
'member',
|
||||
'billing_name',
|
||||
'source',
|
||||
'payment_for_document_type',
|
||||
'payment_for_document',
|
||||
'payment_received',
|
||||
'payment_for_certificate',
|
||||
'currency',
|
||||
'amount',
|
||||
'order_id',
|
||||
'payment_id',
|
||||
'gstin',
|
||||
'pan',
|
||||
'address',
|
||||
],
|
||||
auto: true,
|
||||
orderBy: 'modified desc',
|
||||
})
|
||||
|
||||
watch(
|
||||
[billingName, member, paymentReceived, paymentForCertificate],
|
||||
([
|
||||
newBillingName,
|
||||
newMember,
|
||||
newPaymentReceived,
|
||||
newPaymentForCertificate,
|
||||
]) => {
|
||||
transactions.update({
|
||||
filters: [
|
||||
newBillingName ? [['billing_name', 'like', `%${newBillingName}%`]] : [],
|
||||
newMember ? [['member', '=', newMember]] : [],
|
||||
newPaymentReceived
|
||||
? [['payment_received', '=', newPaymentReceived]]
|
||||
: [],
|
||||
newPaymentForCertificate
|
||||
? [['payment_for_certificate', '=', newPaymentForCertificate]]
|
||||
: [],
|
||||
].flat(),
|
||||
})
|
||||
transactions.reload()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const openForm = (transaction: { [key: string]: any }) => {
|
||||
currentTransaction.value = transaction
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
const getCurrencySymbol = (currency: string) => {
|
||||
const currencySymbols: Record<string, string> = {
|
||||
USD: '$',
|
||||
EUR: '€',
|
||||
GBP: '£',
|
||||
INR: '₹',
|
||||
AED: 'د.إ',
|
||||
CHF: 'Fr',
|
||||
JPY: '¥',
|
||||
AUD: '$',
|
||||
}
|
||||
return currencySymbols[currency] || currency
|
||||
}
|
||||
|
||||
const columns = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: __('Billing Name'),
|
||||
icon: 'user',
|
||||
key: 'billing_name',
|
||||
width: '30%',
|
||||
},
|
||||
{
|
||||
label: __('Amount'),
|
||||
icon: 'dollar-sign',
|
||||
key: 'amount',
|
||||
width: '20%',
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
label: __('Payment Received'),
|
||||
icon: 'check-circle',
|
||||
key: 'payment_received',
|
||||
width: '25%',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
label: __('Payment for Certificate'),
|
||||
icon: 'award',
|
||||
key: 'payment_for_certificate',
|
||||
width: '25%',
|
||||
align: 'center',
|
||||
},
|
||||
]
|
||||
})
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<button
|
||||
v-if="link && !link.onlyMobile"
|
||||
class="flex h-7 cursor-pointer items-center rounded text-ink-gray-8 duration-300 ease-in-out focus:outline-none focus:transition-none focus-visible:rounded focus-visible:ring-2 focus-visible:ring-outline-gray-3"
|
||||
class="flex w-full h-7 cursor-pointer items-center rounded text-ink-gray-8 duration-300 ease-in-out focus:outline-none focus:transition-none focus-visible:rounded focus-visible:ring-2 focus-visible:ring-outline-gray-3"
|
||||
:class="
|
||||
isActive ? 'bg-surface-selected shadow-sm' : 'hover:bg-surface-gray-2'
|
||||
"
|
||||
@@ -59,15 +59,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<ContactUsEmail v-model="showContactForm" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { Tooltip } from 'frappe-ui'
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import ContactUsEmail from '@/components/ContactUsEmail.vue'
|
||||
import * as icons from 'lucide-vue-next'
|
||||
|
||||
const router = useRouter()
|
||||
const emit = defineEmits(['openModal', 'deletePage'])
|
||||
const showContactForm = ref(false)
|
||||
|
||||
const props = defineProps({
|
||||
link: {
|
||||
@@ -82,18 +85,31 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
activeTab: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
function handleClick() {
|
||||
if (router.hasRoute(props.link.to)) {
|
||||
router.push({ name: props.link.to })
|
||||
} else if (props.link.to?.includes('@')) {
|
||||
showContactForm.value = true
|
||||
} else if (props.link.to) {
|
||||
if (props.link.to.startsWith('http')) {
|
||||
window.open(props.link.to, '_blank')
|
||||
return
|
||||
}
|
||||
window.location.href = `/${props.link.to}`
|
||||
}
|
||||
}
|
||||
|
||||
const isActive = computed(() => {
|
||||
return props.link?.activeFor?.includes(router.currentRoute.value.name)
|
||||
return (
|
||||
props.link?.activeFor?.includes(router.currentRoute.value.name) ||
|
||||
(props.activeTab && props.link?.label?.includes(props.activeTab))
|
||||
)
|
||||
})
|
||||
|
||||
const openModal = (link) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div v-if="heatmap.data">
|
||||
<div class="text-lg font-semibold mb-2">
|
||||
<div class="text-lg font-semibold mb-2 text-ink-gray-9">
|
||||
{{ heatmap.data.total_activities }}
|
||||
{{
|
||||
heatmap.data.total_activities > 1 ? __('activities') : __('activity')
|
||||
|
||||
@@ -1,60 +1,62 @@
|
||||
<template>
|
||||
<Dropdown class="p-2" :options="userDropdownOptions">
|
||||
<template v-slot="{ open }">
|
||||
<button
|
||||
class="flex h-12 py-2 items-center rounded-md duration-300 ease-in-out"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'px-0 w-auto'
|
||||
: open
|
||||
? 'bg-surface-white shadow-sm px-2 w-52'
|
||||
: 'hover:bg-surface-gray-3 px-2 w-52'
|
||||
"
|
||||
>
|
||||
<img
|
||||
v-if="branding.data?.banner_image"
|
||||
:src="branding.data?.banner_image.file_url"
|
||||
class="w-8 h-8 rounded flex-shrink-0"
|
||||
/>
|
||||
<LMSLogo v-else class="w-8 h-8 rounded flex-shrink-0" />
|
||||
<div
|
||||
class="flex flex-1 flex-col text-left duration-300 ease-in-out"
|
||||
<div class="p-2">
|
||||
<Dropdown :options="userDropdownOptions">
|
||||
<template v-slot="{ open }">
|
||||
<button
|
||||
class="flex h-12 py-2 items-center rounded-md duration-300 ease-in-out"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'opacity-0 ml-0 w-0 overflow-hidden'
|
||||
: 'opacity-100 ml-2 w-auto'
|
||||
? 'px-0 w-auto'
|
||||
: open
|
||||
? 'bg-surface-white shadow-sm px-2 w-52'
|
||||
: 'hover:bg-surface-gray-3 px-2 w-52'
|
||||
"
|
||||
>
|
||||
<div class="text-base font-medium text-ink-gray-9 leading-none">
|
||||
<span
|
||||
v-if="
|
||||
branding.data?.app_name && branding.data?.app_name != 'Frappe'
|
||||
"
|
||||
<img
|
||||
v-if="branding.data?.banner_image"
|
||||
:src="branding.data?.banner_image.file_url"
|
||||
class="w-8 h-8 rounded flex-shrink-0"
|
||||
/>
|
||||
<LMSLogo v-else class="w-8 h-8 rounded flex-shrink-0" />
|
||||
<div
|
||||
class="flex flex-1 flex-col text-left duration-300 ease-in-out"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'opacity-0 ml-0 w-0 overflow-hidden'
|
||||
: 'opacity-100 ml-2 w-auto'
|
||||
"
|
||||
>
|
||||
<div class="text-base font-medium text-ink-gray-9 leading-none">
|
||||
<span
|
||||
v-if="
|
||||
branding.data?.app_name && branding.data?.app_name != 'Frappe'
|
||||
"
|
||||
>
|
||||
{{ branding.data?.app_name }}
|
||||
</span>
|
||||
<span v-else> Learning </span>
|
||||
</div>
|
||||
<div
|
||||
v-if="userResource.data"
|
||||
class="mt-1 text-sm text-ink-gray-7 leading-none"
|
||||
>
|
||||
{{ branding.data?.app_name }}
|
||||
</span>
|
||||
<span v-else> Learning </span>
|
||||
{{ convertToTitleCase(userResource.data?.full_name) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="userResource.data"
|
||||
class="mt-1 text-sm text-ink-gray-7 leading-none"
|
||||
class="duration-300 ease-in-out"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'opacity-0 ml-0 w-0 overflow-hidden'
|
||||
: 'opacity-100 ml-2 w-auto'
|
||||
"
|
||||
>
|
||||
{{ convertToTitleCase(userResource.data?.full_name) }}
|
||||
<ChevronDown class="h-4 w-4 text-ink-gray-7" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="duration-300 ease-in-out"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'opacity-0 ml-0 w-0 overflow-hidden'
|
||||
: 'opacity-100 ml-2 w-auto'
|
||||
"
|
||||
>
|
||||
<ChevronDown class="h-4 w-4 text-ink-gray-7" />
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</button>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</div>
|
||||
<SettingsModal
|
||||
v-if="userResource.data?.is_moderator"
|
||||
v-model="showSettingsModal"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</div>
|
||||
<div v-if="batch.data.courses.length">
|
||||
<div class="flex items-center mt-10">
|
||||
<div class="text-2xl font-semibold">
|
||||
<div class="text-2xl font-semibold text-ink-gray-9">
|
||||
{{ __('Courses') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="text-ink-gray-5">
|
||||
{{ __('Payment for ') }} {{ type }}:
|
||||
</div>
|
||||
<div class="leading-5">
|
||||
<div class="leading-5 text-ink-gray-9">
|
||||
{{ orderSummary.data.title }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -31,7 +31,7 @@
|
||||
<div class="text-ink-gray-5">
|
||||
{{ __('Original Amount') }}
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="text-ink-gray-9">
|
||||
{{ orderSummary.data.original_amount_formatted }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,17 +42,17 @@
|
||||
<div class="text-ink-gray-5">
|
||||
{{ __('GST Amount') }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-ink-gray-9">
|
||||
{{ orderSummary.data.gst_amount_formatted }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center justify-between border-t border-outline-gray-3 pt-4 mt-2"
|
||||
>
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Total') }}
|
||||
</div>
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ orderSummary.data.total_amount_formatted }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
<div class="flex-1 lg:mr-10">
|
||||
<div class="mb-5">
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Address') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
918
frontend/src/pages/CourseCreatorProfile.vue
Normal file
918
frontend/src/pages/CourseCreatorProfile.vue
Normal file
@@ -0,0 +1,918 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-white">
|
||||
<NoPermission v-if="!$user.data" />
|
||||
|
||||
<div v-else-if="profile.error" class="p-6">
|
||||
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-sm p-6 border border-red-200">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки профиля: {{ profile.error.message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="profile.data">
|
||||
<header class="sticky top-0 z-10 flex items-center justify-between bg-white px-6 py-4">
|
||||
<Breadcrumbs class="h-7" :items="breadcrumbs" />
|
||||
</header>
|
||||
|
||||
<div class="mx-auto max-w-6xl px-4 py-6">
|
||||
<!-- Profile Header -->
|
||||
<div v-if="!schoolProfileNotFound" class="bg-gradient-to-r from-teal-100 to-teal-600 rounded-2xl shadow-sm border border-gray-200 p-6 -mt-4 relative">
|
||||
<div class="flex flex-col md:flex-row md:items-center gap-6">
|
||||
<div class="flex-1">
|
||||
<h2 class="text-3xl font-bold text-gray-900">{{ displayName }}</h2>
|
||||
<div
|
||||
v-if="profile.data.bio"
|
||||
v-html="
|
||||
DOMPurify.sanitize(decodeEntities(profile.data.bio), {
|
||||
ALLOWED_TAGS: [
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'a',
|
||||
'p',
|
||||
'br',
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
'img',
|
||||
],
|
||||
ALLOWED_ATTR: ['href', 'target', 'rel', 'src'],
|
||||
})
|
||||
"
|
||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-outline-gray-2 prose-th:border-outline-gray-2 prose-td:relative prose-th:relative prose-th:bg-surface-gray-2 prose-sm max-w-none !whitespace-normal mt-2 text-gray-700"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div v-if="$user.data && isSessionUser() && !schoolProfileNotFound" class="md:ml-auto">
|
||||
<Button @click="toggleEdit()" class="bg-white hover:bg-gray-100 px-5 py-2.5 rounded-lg transition-colors duration-200">
|
||||
<template #prefix>
|
||||
<Edit class="w-4 h-4 stroke-1.5" />
|
||||
</template>
|
||||
{{ editMode ? 'Отменить редактирование' : 'Редактировать профиль' }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VIEW MODE -->
|
||||
<div v-if="!editMode" class="mt-6">
|
||||
<!-- Пустой профиль -->
|
||||
<div v-if="schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="p-8 text-center">
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="mx-auto w-20 h-20 bg-teal-100 rounded-full flex items-center justify-center mb-6">
|
||||
<svg class="w-10 h-10 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h3 class="text-2xl font-bold text-gray-900 mb-3">Профиль преподавателя еще не заполнен</h3>
|
||||
|
||||
<p class="text-gray-600 mb-6">
|
||||
Чтобы начать создавать и проводить курсы, заполните информацию о себе.
|
||||
Это поможет студентам лучше узнать вас как преподавателя.
|
||||
</p>
|
||||
|
||||
<div class="bg-teal-50 border border-teal-100 rounded-lg p-5 mb-6 text-left">
|
||||
<h4 class="font-semibold text-teal-800 mb-3 flex items-center gap-2">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Заполнив профиль, вы сможете:
|
||||
</h4>
|
||||
<ul class="space-y-2 text-sm text-gray-700">
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Создавать и проводить собственные курсы</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Привлекать студентов с помощью подробного профиля</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Показать свою экспертизу и опыт</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@click="toggleEdit()"
|
||||
class="bg-teal-600 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 shadow-sm hover:shadow-md"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
||||
</svg>
|
||||
</template>
|
||||
Заполнить профиль создателя курса
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загружающийся профиль -->
|
||||
<div v-else-if="schoolProfile.loading" class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ошибка загрузки (кроме DoesNotExistError) -->
|
||||
<div v-else-if="schoolProfile.error && !schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-red-200 p-6">
|
||||
<p class="text-red-500 text-lg font-medium">{{__('Error loading course creator data:')}} {{ schoolProfile.error.message }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Загруженный профиль -->
|
||||
<div v-else-if="schoolProfile.data && !schoolProfileNotFound" class="space-y-6">
|
||||
<!-- Основная информация -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Основная информация</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Last name:')}}:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.last_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Name:')}}:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.first_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Middle name:')}}</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.middle_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Date of birth:')}}</span>
|
||||
<span class="text-gray-900">{{ formattedDate(schoolProfile.data.birth_date) || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Phone:')}}</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.phone) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Email:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.email_private) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Telegram:</span>
|
||||
<div class="flex-1">
|
||||
<a v-if="schoolProfile.data.telegram"
|
||||
:href="formatTelegram(schoolProfile.data.telegram)"
|
||||
target="_blank"
|
||||
class="inline-flex items-center gap-2 text-primary-600 hover:text-primary-700 font-medium transition-colors">
|
||||
<span>{{ schoolProfile.data.telegram.replace('@', '') }}</span>
|
||||
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69.01-.03.01-.14-.06-.2-.07-.06-.17-.04-.24-.02-.1.02-1.69 1.09-4.78 3.2-.45.31-.86.46-1.23.45-.41-.01-1.2-.23-1.79-.42-.72-.23-1.29-.36-1.24-.76.03-.24.37-.48 1.01-.74 3.97-1.67 6.62-2.77 7.94-3.31 3.26-1.33 3.94-1.56 4.38-1.56.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<span v-else class="text-gray-500">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('University:')}}</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.school || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Education level:')}}</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.education_level || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('The direction of training:')}}</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.major || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-40 text-gray-700 font-medium">{{__('Educational program:')}}</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.program || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Год окончания:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.graduation_year || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- О себе, опыте и достижениях -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Коротко о себе</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.about_me || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Опыт работы</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.experience || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Достижения</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.achievement || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="text-center py-12">
|
||||
<div class="mx-auto w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4">
|
||||
<svg class="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-semibold text-gray-900 mb-2">Данные профиля не найдены</h3>
|
||||
<p class="text-gray-600">Информация о репетиторе/эксперте отсутствует</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EDIT MODE -->
|
||||
<div v-else class="mt-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">{{__('Profile Editing')}}</h3>
|
||||
<p class="text-sm text-gray-200 mt-1">{{__('Fill in the information about yourself')}}</p>
|
||||
</div>
|
||||
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Левая колонка -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">{{__('Personal information')}}</h4>
|
||||
|
||||
<Input
|
||||
v-model="form.last_name"
|
||||
:label="__('Last name:')"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.first_name"
|
||||
:label="__('Name:')"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.middle_name"
|
||||
:label="__('Middle name:')"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">{{__('Date of birth:')}}</label>
|
||||
<DatePicker
|
||||
v-model="form.birth_date"
|
||||
class="w-full bg-gray-50 border-gray-300 rounded-lg focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-model="form.phone"
|
||||
:label="__('Phone:')"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.email_private"
|
||||
label="Email"
|
||||
type="email"
|
||||
placeholder="example@email.com"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.telegram"
|
||||
label="Telegram"
|
||||
placeholder="username или t.me/username"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Правая колонка -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Образование</h4>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Университет</label>
|
||||
<input
|
||||
type="text"
|
||||
v-model="schoolQuery"
|
||||
@input="debouncedSearchSchool"
|
||||
class="w-full bg-gray-50 border border-gray-300 rounded-lg px-4 py-2.5 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors"
|
||||
placeholder="Начните вводить название университета"
|
||||
/>
|
||||
<div v-if="schoolResults.length" class="mt-2 border border-gray-300 rounded-lg overflow-hidden shadow-lg bg-white">
|
||||
<div
|
||||
v-for="s in schoolResults"
|
||||
:key="s.school"
|
||||
class="p-3 cursor-pointer hover:bg-primary-50 border-b border-gray-100 last:border-b-0 transition-colors"
|
||||
@click="selectSchool(s)"
|
||||
>
|
||||
<div class="font-medium text-gray-900">{{ s.school }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">{{ s.adress }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.school_name && !schoolResults.length" class="mt-2 text-sm text-gray-600">
|
||||
<span class="font-medium">Выбрана:</span> {{ form.school }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Уровень образования</label>
|
||||
<Select
|
||||
v-model="form.education_level"
|
||||
:options="['Бакалавриат','Магистратура','Аспирантура','Базовое высшее образование','Специализированное высшее образование','Профессиональная переподготовка','Повышение квалификации']"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Направление подготовки</label>
|
||||
<input
|
||||
type="text"
|
||||
v-model="majorQuery"
|
||||
@input="debouncedSearchMajor"
|
||||
class="w-full bg-gray-50 border border-gray-300 rounded-lg px-4 py-2.5 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors"
|
||||
placeholder="Начните вводить название направления"
|
||||
/>
|
||||
<div v-if="majorResults.length" class="mt-2 border border-gray-300 rounded-lg overflow-hidden shadow-lg bg-white">
|
||||
<div
|
||||
v-for="m in majorResults"
|
||||
:key="m.major"
|
||||
class="p-3 cursor-pointer hover:bg-primary-50 border-b border-gray-100 last:border-b-0 transition-colors"
|
||||
@click="selectMajor(m)"
|
||||
>
|
||||
<div class="font-medium text-gray-900">{{ m.major_name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.major_name && !majorResults.length" class="mt-2 text-sm text-gray-600">
|
||||
<span class="font-medium">Выбрано:</span> {{ form.major_name }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-model="form.program"
|
||||
label="Образовательная программа"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.graduation_year"
|
||||
label="Год окончания"
|
||||
placeholder="например, 2025"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Текстовые поля -->
|
||||
<div class="mt-8 space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Дополнительная информация</h4>
|
||||
|
||||
<Textarea
|
||||
v-model="form.about_me"
|
||||
label="Коротко о себе"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
v-model="form.experience"
|
||||
label="Опыт работы"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
v-model="form.achievement"
|
||||
label="Достижения"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="mt-8 pt-6 border-t border-gray-200 flex gap-3">
|
||||
<Button
|
||||
@click="saveProfile"
|
||||
:loading="saving"
|
||||
class="bg-teal-400 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 flex items-center gap-2"
|
||||
>
|
||||
{{ saving ? 'Сохранение...' : 'Сохранить изменения' }}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
@click="toggleEdit()"
|
||||
class="border-gray-300 text-gray-700 hover:bg-gray-50 px-6 py-3 rounded-lg font-medium transition-colors duration-200"
|
||||
>
|
||||
Отмена
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex items-center justify-center min-h-screen">
|
||||
<div class="text-center">
|
||||
<div class="animate-spin rounded-full h-16 w-16 border-b-2 border-primary-600 mx-auto"></div>
|
||||
<p class="mt-4 text-lg text-gray-600">Загрузка профиля...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Плавные переходы для интерактивных элементов */
|
||||
.border-gray-300 {
|
||||
transition: border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.bg-primary-50 {
|
||||
background-color: rgba(59, 130, 246, 0.05);
|
||||
}
|
||||
|
||||
/* Стилизация скроллбара для выпадающих списков */
|
||||
.overflow-auto::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.overflow-auto::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-auto::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-auto::-webkit-scrollbar-thumb:hover {
|
||||
background: #a1a1a1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject, watch, onMounted } from 'vue';
|
||||
import { Breadcrumbs, createResource, Button, Input, DatePicker, Select, Textarea } from 'frappe-ui';
|
||||
import { sessionStore } from '@/stores/session';
|
||||
import NoPermission from '@/components/NoPermission.vue';
|
||||
import { Edit } from 'lucide-vue-next';
|
||||
import { convertToTitleCase, updateDocumentTitle } from '@/utils';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { decodeEntities } from '@/utils'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
const { user } = sessionStore();
|
||||
const $user = inject('$user');
|
||||
const schoolProfileNotFound = ref(false);
|
||||
|
||||
// Логирование инициализации
|
||||
console.log('[DEBUG] Инициализация компонента:', {
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
username: $user.data?.username,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
username: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const effectiveUsername = computed(() => {
|
||||
const username = props.username || $user.data?.username || '';
|
||||
console.log('[DEBUG] Вычисление effectiveUsername:', { propsUsername: props.username, sessionUsername: $user.data?.username, result: username });
|
||||
return username;
|
||||
});
|
||||
|
||||
const editMode = ref(false);
|
||||
const saving = ref(false);
|
||||
|
||||
const profile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
makeParams(values) {
|
||||
const username = effectiveUsername.value;
|
||||
console.log('[DEBUG] Запрос profile:', { doctype: 'User', filters: { username } });
|
||||
return {
|
||||
doctype: 'User',
|
||||
filters: { username },
|
||||
};
|
||||
},
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль пользователя: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const schoolProfile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user:user },
|
||||
},
|
||||
auto: false,
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль школьника загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
// Проверяем, является ли ошибка "не найдено"
|
||||
if (error.exc_type === 'DoesNotExistError' || error.message?.includes('DoesNotExist')) {
|
||||
console.log('[DEBUG] Профиль школьника не найден, создаем новый');
|
||||
schoolProfileNotFound.value = true;
|
||||
} else {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля школьника:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль школьника: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const form = ref({
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
middle_name: '',
|
||||
birth_date: '',
|
||||
phone: '',
|
||||
email_private: '',
|
||||
telegram: '',
|
||||
school: '',
|
||||
education_level: '',
|
||||
major: '',
|
||||
program: '',
|
||||
graduation_year: '',
|
||||
experience: '',
|
||||
achievement: '',
|
||||
about_me: ''
|
||||
});
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
const username = effectiveUsername.value;
|
||||
const crumbs = [
|
||||
{
|
||||
label: 'People',
|
||||
route: { name: 'People' },
|
||||
},
|
||||
{
|
||||
label: profile.data?.full_name || 'Профиль',
|
||||
route: username ? {
|
||||
name: 'Profile',
|
||||
params: { username },
|
||||
} : undefined,
|
||||
},
|
||||
];
|
||||
console.log('[DEBUG] Хлебные крошки:', crumbs);
|
||||
return crumbs;
|
||||
});
|
||||
|
||||
const pageMeta = computed(() => {
|
||||
const meta = {
|
||||
title: profile.data?.full_name || 'Профиль',
|
||||
description: profile.data?.headline || '',
|
||||
};
|
||||
console.log('[DEBUG] Мета-данные страницы:', meta);
|
||||
return meta;
|
||||
});
|
||||
|
||||
const displayName = computed(() => {
|
||||
if (!profile.data) {
|
||||
console.log('[DEBUG] displayName: profile.data не загружен');
|
||||
return 'Загрузка...';
|
||||
}
|
||||
const name = profile.data?.full_name || `${form.value.first_name || ''} ${form.value.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Отображаемое имя:', name);
|
||||
return name;
|
||||
});
|
||||
|
||||
const isSessionUser = () => {
|
||||
const sessionUser = $user.data?.username;
|
||||
const profileUser = effectiveUsername.value;
|
||||
const isSession = sessionUser === profileUser;
|
||||
console.log('[DEBUG] Проверка isSessionUser:', { sessionUser, profileUser, isSession });
|
||||
return isSession;
|
||||
};
|
||||
|
||||
function formattedDate(d) {
|
||||
if (!d) return '';
|
||||
try {
|
||||
return new Date(d).toLocaleDateString('ru-RU');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка форматирования даты:', e, { date: d });
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
function maskPrivate(val) {
|
||||
if (!val) return '-';
|
||||
if (val.includes('@')) {
|
||||
const parts = val.split('@');
|
||||
return parts[0].slice(0, 1) + '***@' + parts[1];
|
||||
}
|
||||
return val.slice(0, 3) + '***' + val.slice(-2);
|
||||
}
|
||||
|
||||
function formatTelegram(t) {
|
||||
if (!t) return '';
|
||||
if (t.startsWith('t.me/') || t.startsWith('https://t.me/')) return (t.startsWith('http') ? t : 'https://' + t);
|
||||
return 'https://t.me/' + t.replace(/^@/, '');
|
||||
}
|
||||
|
||||
function fillFormFromProfile() {
|
||||
console.log('[DEBUG] Заполнение формы:', {
|
||||
schoolProfile: schoolProfile.data,
|
||||
profile: profile.data,
|
||||
currentForm: JSON.stringify(form.value, null, 2),
|
||||
});
|
||||
form.value.first_name = schoolProfile.data?.first_name || profile.data?.first_name || '';
|
||||
form.value.last_name = schoolProfile.data?.last_name || profile.data?.last_name || '';
|
||||
form.value.middle_name = schoolProfile.data?.middle_name || '';
|
||||
form.value.birth_date = schoolProfile.data?.birth_date || '';
|
||||
form.value.phone = schoolProfile.data?.phone || '';
|
||||
form.value.email_private = schoolProfile.data?.email_private || '';
|
||||
form.value.telegram = schoolProfile.data?.telegram || '';
|
||||
form.value.school = schoolProfile.data?.school || '';
|
||||
form.value.education_level = schoolProfile.data?.education_level || '';
|
||||
form.value.major = schoolProfile.data?.major || '';
|
||||
form.value.program = schoolProfile.data?.program || '';
|
||||
form.value.graduation_year = schoolProfile.data?.graduation_year || '';
|
||||
form.value.experience = schoolProfile.data?.experience || '';
|
||||
form.value.achievement = schoolProfile.data?.achievement || '';
|
||||
form.value.about_me = schoolProfile.data?.about_me || '';
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
|
||||
function toggleEdit() {
|
||||
editMode.value = !editMode.value;
|
||||
if (editMode.value) fillFormFromProfile();
|
||||
console.log('[DEBUG] Переключение режима редактирования:', { editMode: editMode.value });
|
||||
}
|
||||
|
||||
function validateExams(exams) {
|
||||
console.log('[DEBUG] Валидация exams:', { exams, validOptions: examOptions });
|
||||
return exams.every(exam => examOptions.includes(exam));
|
||||
}
|
||||
|
||||
function validateLearnSubjects(subjects) {
|
||||
console.log('[DEBUG] Валидация learn_subjects:', { subjects, validOptions: learnOptions });
|
||||
return subjects.every(subject => learnOptions.includes(subject));
|
||||
}
|
||||
|
||||
async function saveProfile() {
|
||||
console.log('[DEBUG] Сохранение профиля:', { form: form.value });
|
||||
saving.value = true;
|
||||
try {
|
||||
// Создаём копию данных формы
|
||||
const formData = { ...form.value };
|
||||
console.log('[DEBUG] Копия formData:', JSON.stringify(formData, null, 2));
|
||||
|
||||
// Обновление full_name в User, если нужно
|
||||
if (formData.first_name || formData.last_name) {
|
||||
const fullName = `${formData.first_name || ''} ${formData.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Обновление User.full_name:', { name: profile.data?.name, fullName });
|
||||
await createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
params: {
|
||||
doctype: 'User',
|
||||
name: profile.data?.name,
|
||||
fieldname: 'full_name',
|
||||
value: fullName,
|
||||
},
|
||||
}).submit();
|
||||
}
|
||||
|
||||
// Получаем docname
|
||||
let docname = '';
|
||||
try {
|
||||
await schoolProfile.reload();
|
||||
console.log('[DEBUG] Schoolprofile:', { schoolProfile });
|
||||
docname = schoolProfile?.data?.name;
|
||||
console.log('[DEBUG] Выбранное имя документа:', docname);
|
||||
} catch (error) {
|
||||
console.log('[DEBUG] Ошибка загрузки schoolProfile, продолжаем с profile:', error.message);
|
||||
}
|
||||
|
||||
// Формируем payload из копии данных формы
|
||||
let payload = {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
user: profile.data?.name,
|
||||
first_name: formData.first_name,
|
||||
last_name: formData.last_name,
|
||||
middle_name: formData.middle_name,
|
||||
birth_date: formData.birth_date,
|
||||
phone: formData.phone,
|
||||
email_private: formData.email_private,
|
||||
telegram: formData.telegram,
|
||||
school: formData.school || '',
|
||||
education_level: formData.education_level,
|
||||
major: formData.major || '',
|
||||
program: formData.program,
|
||||
graduation_year: formData.graduation_year,
|
||||
experience: formData.experience,
|
||||
achievement: formData.achievement,
|
||||
about_me: formData.about_me,
|
||||
last_updated: new Date().toISOString(),
|
||||
};
|
||||
console.log('[DEBUG] Сохранение Schoolchildren Profile (payload):', { docname, payload });
|
||||
|
||||
// Сохранение или создание документа
|
||||
if (docname) {
|
||||
await createResource({
|
||||
url: 'frappe.client.save',
|
||||
params: { doc: { ...schoolProfile.data, ...payload } },
|
||||
}).submit();
|
||||
} else {
|
||||
await createResource({
|
||||
url: 'frappe.client.insert',
|
||||
params: { doc: payload },
|
||||
}).submit();
|
||||
}
|
||||
|
||||
editMode.value = false;
|
||||
schoolProfileNotFound.value = false;
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint('Профиль сохранён');
|
||||
console.log('[DEBUG] Профиль успешно сохранён');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка при сохранении профиля:', e);
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: (e && e.message) || 'Ошибка при сохранении',
|
||||
indicator: 'red',
|
||||
});
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
await schoolProfile.reload();
|
||||
}
|
||||
|
||||
const schoolQuery = ref('');
|
||||
const schoolResults = ref([]);
|
||||
|
||||
async function searchSchool(q) {
|
||||
if (!q) {
|
||||
schoolResults.value = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log('[DEBUG] Поиск школы:', { query: q });
|
||||
const res = await createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'Schools',
|
||||
fields: ['school', 'address'],
|
||||
filters: [['school', 'like', '%' + q + '%']],
|
||||
limit_page_length: 20,
|
||||
},
|
||||
}).submit();
|
||||
schoolResults.value = res || [];
|
||||
console.log('[DEBUG] Результаты поиска школы:', schoolResults.value);
|
||||
} catch (e) {
|
||||
schoolResults.value = [];
|
||||
console.error('[DEBUG] Ошибка поиска школы:', e);
|
||||
}
|
||||
}
|
||||
|
||||
const debouncedSearchSchool = debounce(() => searchSchool(schoolQuery.value), 300);
|
||||
|
||||
function selectSchool(s) {
|
||||
form.value.school = s.school;
|
||||
//form.value.school_name = s.school_name;
|
||||
schoolResults.value = [];
|
||||
schoolQuery.value = s.school;
|
||||
console.log('[DEBUG] Выбрана школа:', { school: s });
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
const majorQuery = ref('');
|
||||
const majorResults = ref([]);
|
||||
|
||||
async function searchMajor(q) {
|
||||
if (!q) {
|
||||
majorResults.value = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log('[DEBUG] Поиск направления:', { query: q });
|
||||
const res = await createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'Majors',
|
||||
fields: ['code', 'major_name'],
|
||||
filters: [['major_name', 'like', '%' + q + '%']],
|
||||
limit_page_length: 20,
|
||||
},
|
||||
}).submit();
|
||||
majorResults.value = res || [];
|
||||
console.log('[DEBUG] Результаты поиска направления:', majorResults.value);
|
||||
} catch (e) {
|
||||
majorResults.value = [];
|
||||
console.error('[DEBUG] Ошибка поиска направления:', e);
|
||||
}
|
||||
}
|
||||
|
||||
const debouncedSearchMajor = debounce(() => searchMajor(majorQuery.value), 300);
|
||||
|
||||
function selectMajor(m) {
|
||||
form.value.major = m.major_name;
|
||||
//form.value.school_name = s.school_name;
|
||||
majorResults.value = [];
|
||||
majorQuery.value = m.major_name;
|
||||
console.log('[DEBUG] Выбрана школа:', { major: m });
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('[DEBUG] Компонент смонтирован:', {
|
||||
propsUsername: props.username,
|
||||
sessionUsername: $user.data?.username,
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
});
|
||||
if ($user.data) {
|
||||
console.log('[DEBUG] Запуск profile.reload()');
|
||||
profile.reload();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.username,
|
||||
(newUsername, oldUsername) => {
|
||||
console.log('[DEBUG] Изменение props.username:', { old: oldUsername, new: newUsername });
|
||||
profile.reload();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => profile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение profile.data:', { old: oldData, new: newData });
|
||||
if (newData) {
|
||||
console.log('[DEBUG] Запуск schoolProfile.reload()');
|
||||
schoolProfile.reload();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => schoolProfile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение schoolProfile.data:', { old: oldData, new: newData });
|
||||
if (newData && !editMode.value && !schoolProfileNotFound.value) {
|
||||
console.log('[DEBUG] Заполнение формы из schoolProfile');
|
||||
fillFormFromProfile();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => effectiveUsername.value,
|
||||
(newUsername) => {
|
||||
console.log('[DEBUG] Изменение effectiveUsername для schoolProfile:', newUsername);
|
||||
schoolProfile.update({
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user: newUsername },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
@@ -56,7 +56,7 @@
|
||||
<CourseInstructors :instructors="course.data.instructors" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="course.data.tags" class="flex my-4 w-fit">
|
||||
<div v-if="course.data.tags" class="flex flex-wrap gap-2 mt-3 mb-3 max-w-full">
|
||||
<Badge
|
||||
theme="gray"
|
||||
size="lg"
|
||||
@@ -103,9 +103,10 @@ import {
|
||||
Tooltip,
|
||||
usePageMeta,
|
||||
} from 'frappe-ui'
|
||||
import { computed, watch } from 'vue'
|
||||
import { computed, inject, watch } from 'vue'
|
||||
import { Users, Star } from 'lucide-vue-next'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { useRouter } from 'vue-router'
|
||||
import CourseCardOverlay from '@/components/CourseCardOverlay.vue'
|
||||
import CourseOutline from '@/components/CourseOutline.vue'
|
||||
import CourseReviews from '@/components/CourseReviews.vue'
|
||||
@@ -114,6 +115,8 @@ import CourseInstructors from '@/components/CourseInstructors.vue'
|
||||
import RelatedCourses from '@/components/RelatedCourses.vue'
|
||||
|
||||
const { brand } = sessionStore()
|
||||
const router = useRouter()
|
||||
const user = inject('$user')
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -140,6 +143,29 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(course, () => {
|
||||
if (
|
||||
!isInstructor() &&
|
||||
!user.data?.is_moderator &&
|
||||
!course.data?.published &&
|
||||
!course.data?.upcoming
|
||||
) {
|
||||
router.push({
|
||||
name: 'Courses',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const isInstructor = () => {
|
||||
let user_is_instructor = false
|
||||
course.data?.instructors.forEach((instructor) => {
|
||||
if (!user_is_instructor && instructor.name == user.data?.name) {
|
||||
user_is_instructor = true
|
||||
}
|
||||
})
|
||||
return user_is_instructor
|
||||
}
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
let items = [{ label: 'Courses', route: { name: 'Courses' } }]
|
||||
items.push({
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</header>
|
||||
<div class="mt-5 mb-5">
|
||||
<div class="px-5 md:px-10 pb-5 mb-5 space-y-5 border-b">
|
||||
<div class="text-lg font-semibold mb-4">
|
||||
<div class="text-lg font-semibold mb-4 text-ink-gray-9">
|
||||
{{ __('Details') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
@@ -138,7 +138,7 @@
|
||||
</div>
|
||||
|
||||
<div class="px-5 md:px-10 pb-5 mb-5 space-y-5 border-b">
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Settings') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
@@ -178,7 +178,7 @@
|
||||
</div>
|
||||
|
||||
<div class="px-5 md:px-10 pb-5 mb-5 space-y-5 border-b">
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('About the Course') }}
|
||||
</div>
|
||||
<FormControl
|
||||
@@ -234,7 +234,7 @@
|
||||
</div>
|
||||
|
||||
<div class="px-5 md:px-10 pb-5 space-y-5 border-b">
|
||||
<div class="text-lg font-semibold mt-5">
|
||||
<div class="text-lg font-semibold mt-5 text-ink-gray-9">
|
||||
{{ __('Pricing and Certification') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-5">
|
||||
@@ -260,29 +260,41 @@
|
||||
v-if="course.paid_course || course.paid_certificate"
|
||||
v-model="course.course_price"
|
||||
:label="__('Amount')"
|
||||
:required="course.paid_course || course.paid_certificate"
|
||||
/>
|
||||
<Link
|
||||
v-if="course.paid_certificate"
|
||||
doctype="Course Evaluator"
|
||||
v-model="course.evaluator"
|
||||
:label="__('Evaluator')"
|
||||
:required="course.paid_certificate"
|
||||
:onCreate="
|
||||
(value, close) => openSettings('Evaluators', close)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<Link
|
||||
v-if="course.paid_course || course.paid_certificate"
|
||||
doctype="Currency"
|
||||
v-model="course.currency"
|
||||
:filters="{ enabled: 1 }"
|
||||
:label="__('Currency')"
|
||||
/>
|
||||
<div class="space-y-5">
|
||||
<Link
|
||||
v-if="course.paid_course || course.paid_certificate"
|
||||
doctype="Currency"
|
||||
v-model="course.currency"
|
||||
:filters="{ enabled: 1 }"
|
||||
:label="__('Currency')"
|
||||
:required="course.paid_course || course.paid_certificate"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="course.paid_certificate"
|
||||
v-model="course.timezone"
|
||||
:label="__('Timezone')"
|
||||
:required="course.paid_certificate"
|
||||
:placeholder="__('e.g. IST, UTC, GMT...')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-5 md:px-10 pb-5 space-y-5">
|
||||
<div class="text-lg font-semibold mt-5">
|
||||
<div class="text-lg font-semibold mt-5 text-ink-gray-9">
|
||||
{{ __('Meta Tags') }}
|
||||
</div>
|
||||
<div class="space-y-5">
|
||||
@@ -317,7 +329,6 @@
|
||||
<script setup>
|
||||
import {
|
||||
Breadcrumbs,
|
||||
call,
|
||||
TextEditor,
|
||||
Button,
|
||||
createResource,
|
||||
@@ -388,6 +399,7 @@ const course = reactive({
|
||||
course_price: '',
|
||||
currency: '',
|
||||
evaluator: '',
|
||||
timezone: '',
|
||||
})
|
||||
|
||||
const meta = reactive({
|
||||
|
||||
@@ -134,7 +134,7 @@ const courses = createListResource({
|
||||
doctype: 'LMS Course',
|
||||
url: 'lms.lms.utils.get_courses',
|
||||
cache: ['courses', user.data?.name],
|
||||
pageLength: pageLength.value,
|
||||
//pageLength: pageLength.value,
|
||||
start: start.value,
|
||||
onSuccess(data) {
|
||||
setCategories(data)
|
||||
@@ -229,7 +229,7 @@ const updateTabFilter = () => {
|
||||
delete filters.value['published_on']
|
||||
delete filters.value['upcoming']
|
||||
|
||||
if (currentTab.value == 'Enrolled' && user.data?.is_student) {
|
||||
if ((currentTab.value == 'Enrolled' && user.data?.is_student) || (currentTab.value == 'Зачислен' && user.data?.is_student)) {
|
||||
filters.value['enrolled'] = 1
|
||||
delete filters.value['published']
|
||||
} else {
|
||||
@@ -240,24 +240,25 @@ const updateTabFilter = () => {
|
||||
filters.value['published'] = 1
|
||||
filters.value['upcoming'] = 0
|
||||
filters.value['live'] = 1
|
||||
} else if (currentTab.value == 'Upcoming') {
|
||||
} else if (currentTab.value == 'Upcoming' || currentTab.value == 'Предстоящие') {
|
||||
filters.value['upcoming'] = 1
|
||||
} else if (currentTab.value == 'New') {
|
||||
filters.value['published'] = 1
|
||||
} else if (currentTab.value == 'New' || currentTab.value == 'Новый') {
|
||||
filters.value['published'] = 1
|
||||
filters.value['published_on'] = [
|
||||
'>=',
|
||||
dayjs().add(-3, 'month').format('YYYY-MM-DD'),
|
||||
]
|
||||
} else if (currentTab.value == 'Created') {
|
||||
} else if (currentTab.value == 'Created' || currentTab.value == 'Создано') {
|
||||
filters.value['created'] = 1
|
||||
} else if (currentTab.value == 'Unpublished') {
|
||||
} else if (currentTab.value == 'Unpublished' || currentTab.value == 'Неопубликовано') {
|
||||
filters.value['published'] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const updateStudentFilter = () => {
|
||||
if (!user.data || (user.data?.is_student && currentTab.value != 'Enrolled')) {
|
||||
if (!user.data || (user.data?.is_student && currentTab.value != 'Enrolled') || (currentTab.value != 'Зачислен' && user.data?.is_student)) {
|
||||
filters.value['published'] = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<div v-if="createdCourses.data?.length" class="mt-10">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<span class="font-semibold text-lg">
|
||||
<span class="font-semibold text-lg text-ink-gray-9">
|
||||
{{ __('Courses Created') }}
|
||||
</span>
|
||||
<router-link
|
||||
|
||||
@@ -4,28 +4,29 @@
|
||||
>
|
||||
<Breadcrumbs :items="[{ label: __('Home'), route: { name: 'Home' } }]" />
|
||||
</header> -->
|
||||
<div class="w-full px-5 pt-10 pb-10">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="space-y-2">
|
||||
<div class="text-xl font-bold">
|
||||
<div class="w-full px-5 pt-5 pb-10">
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="text-xl font-bold text-ink-gray-9">
|
||||
{{ __('Hey') }}, {{ user.data?.full_name }} 👋
|
||||
</div>
|
||||
<div class="text-lg text-ink-gray-6">
|
||||
{{ subtitle }}
|
||||
<div>
|
||||
<TabButtons v-if="isAdmin" v-model="currentTab" :buttons="tabs" />
|
||||
<div
|
||||
v-else
|
||||
@click="showStreakModal = true"
|
||||
class="bg-surface-amber-2 px-2 py-1 rounded-md cursor-pointer"
|
||||
>
|
||||
<span> 🔥 </span>
|
||||
<span class="text-ink-gray-9">
|
||||
{{ streakInfo.data?.current_streak }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<TabButtons v-if="isAdmin" v-model="currentTab" :buttons="tabs" />
|
||||
<div
|
||||
v-else
|
||||
@click="showStreakModal = true"
|
||||
class="bg-surface-amber-2 px-2 py-1 rounded-md cursor-pointer"
|
||||
>
|
||||
<span> 🔥 </span>
|
||||
<span>
|
||||
{{ streakInfo.data?.current_streak }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="text-lg text-ink-gray-6 leading-6">
|
||||
{{ subtitle }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
}}
|
||||
{{ __(' you are on a') }}
|
||||
</div>
|
||||
<div class="font-semibold text-xl">
|
||||
<div class="font-semibold text-xl text-ink-gray-9">
|
||||
{{ streakInfo.data?.current_streak }} {{ __('day streak') }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="text-ink-gray-6">
|
||||
{{ __('Current Streak') }}
|
||||
</div>
|
||||
<div class="font-semibold text-lg">
|
||||
<div class="font-semibold text-lg text-ink-gray-9">
|
||||
{{ streakInfo.data?.current_streak }} {{ __('days') }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="text-ink-gray-6">
|
||||
{{ __('Longest Streak') }}
|
||||
</div>
|
||||
<div class="font-semibold text-lg">
|
||||
<div class="font-semibold text-lg text-ink-gray-9">
|
||||
{{ streakInfo.data?.longest_streak }} {{ __('days') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<div v-if="myCourses.data?.length" class="mt-10">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<span class="font-semibold text-lg">
|
||||
<span class="font-semibold text-lg text-ink-gray-9">
|
||||
{{
|
||||
myCourses.data[0].membership
|
||||
? __('My Courses')
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
<div v-if="myBatches.data?.length" class="mt-10">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<span class="font-semibold text-lg">
|
||||
<span class="font-semibold text-lg text-ink-gray-9">
|
||||
{{
|
||||
myBatches.data?.[0].students.includes(user.data?.name)
|
||||
? __('My Batches')
|
||||
@@ -46,7 +46,7 @@
|
||||
name: 'Batches',
|
||||
}"
|
||||
>
|
||||
<span class="flex items-center space-x- 1 text-ink-gray-5 text-xs">
|
||||
<span class="flex items-center space-x-1 text-ink-gray-5 text-xs">
|
||||
<span>
|
||||
{{ __('See all') }}
|
||||
</span>
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="grid grid-cols-2 gap-5 mt-10">
|
||||
<UpcomingEvaluations :forHome="true" />
|
||||
<div v-if="myLiveClasses.data?.length">
|
||||
<div class="font-semibold text-lg mb-3">
|
||||
<div class="font-semibold text-lg mb-3 text-ink-gray-9">
|
||||
{{ __('Upcoming Live Classes') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
|
||||
@@ -99,6 +99,12 @@
|
||||
</template>
|
||||
{{ job.data.type }}
|
||||
</Badge>
|
||||
<Badge v-if="job.data?.work_mode" size="lg">
|
||||
<template #prefix>
|
||||
<BriefcaseBusiness class="size-3 stroke-2 text-ink-gray-7" />
|
||||
</template>
|
||||
{{ job.data.work_mode }}
|
||||
</Badge>
|
||||
<Badge v-if="applicationCount.data" size="lg">
|
||||
<template #prefix>
|
||||
<SquareUserRound class="size-3 stroke-2 text-ink-gray-7" />
|
||||
@@ -152,6 +158,7 @@ import {
|
||||
SquareArrowOutUpRight,
|
||||
FileText,
|
||||
ClipboardType,
|
||||
BriefcaseBusiness,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const user = inject('$user')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</header>
|
||||
<div class="py-5">
|
||||
<div class="container border-b mb-4 pb-5">
|
||||
<div class="text-lg font-semibold mb-4">
|
||||
<div class="text-lg font-semibold mb-4 text-ink-gray-9">
|
||||
{{ __('Job Details') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-5">
|
||||
@@ -27,6 +27,13 @@
|
||||
:options="jobTypes"
|
||||
:required="true"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="job.work_mode"
|
||||
:label="__('Work Mode')"
|
||||
type="select"
|
||||
:options="workModes"
|
||||
:required="true"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<FormControl
|
||||
@@ -52,7 +59,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="container border-b mb-4 pb-5">
|
||||
<div class="text-lg font-semibold mb-4">
|
||||
<div class="text-lg font-semibold mb-4 text-ink-gray-9">
|
||||
{{ __('Company Details') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-5">
|
||||
@@ -151,7 +158,7 @@ import { computed, onMounted, reactive, inject } from 'vue'
|
||||
import { FileText, X } from 'lucide-vue-next'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getFileSize, validateFile } from '@/utils'
|
||||
import { escapeHTML, getFileSize, validateFile } from '@/utils'
|
||||
|
||||
const user = inject('$user')
|
||||
const router = useRouter()
|
||||
@@ -225,6 +232,7 @@ const job = reactive({
|
||||
location: '',
|
||||
country: '',
|
||||
type: 'Full Time',
|
||||
work_mode: 'On-site',
|
||||
status: 'Open',
|
||||
company_name: '',
|
||||
company_website: '',
|
||||
@@ -240,6 +248,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
const saveJob = () => {
|
||||
validateJobFields()
|
||||
if (jobDetail.data) {
|
||||
editJobDetails()
|
||||
} else {
|
||||
@@ -285,6 +294,14 @@ const editJobDetails = () => {
|
||||
)
|
||||
}
|
||||
|
||||
const validateJobFields = () => {
|
||||
Object.keys(job).forEach((key) => {
|
||||
if (key != 'description' && typeof job[key] === 'string') {
|
||||
job[key] = escapeHTML(job[key])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const saveImage = (file) => {
|
||||
job.image = file
|
||||
}
|
||||
@@ -302,6 +319,14 @@ const jobTypes = computed(() => {
|
||||
]
|
||||
})
|
||||
|
||||
const workModes = computed(() => {
|
||||
return [
|
||||
{ label: 'On site', value: 'On-site' },
|
||||
{ label: 'Hybrid', value: 'Hybrid' },
|
||||
{ label: 'Remote', value: 'Remote' },
|
||||
]
|
||||
})
|
||||
|
||||
const jobStatuses = computed(() => {
|
||||
return [
|
||||
{ label: 'Open', value: 'Open' },
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="grid grid-cols-1 gap-2"
|
||||
class="grid grid-cols-1 gap-2 md:grid-cols-4"
|
||||
:class="user.data ? 'md:grid-cols-3' : 'md:grid-cols-2'"
|
||||
>
|
||||
<FormControl
|
||||
@@ -65,6 +65,14 @@
|
||||
:placeholder="__('Type')"
|
||||
@change="updateJobs"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="workMode"
|
||||
type="select"
|
||||
:options="workModes"
|
||||
class="min-w-40 lg:min-w-0 lg:w-32 xl:w-40"
|
||||
:placeholder="__('Work Mode')"
|
||||
@change="updateJobs"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="jobs.data?.length" class="w-full md:w-4/5 mx-auto p-5 pt-0">
|
||||
@@ -103,6 +111,7 @@ import EmptyState from '@/components/EmptyState.vue'
|
||||
|
||||
const user = inject('$user')
|
||||
const jobType = ref(null)
|
||||
const workMode = ref(null)
|
||||
const { brand } = sessionStore()
|
||||
const searchQuery = ref('')
|
||||
const country = ref(null)
|
||||
@@ -116,6 +125,9 @@ onMounted(() => {
|
||||
if (queries.has('type')) {
|
||||
jobType.value = queries.get('type')
|
||||
}
|
||||
if (queries.has('work_mode')) {
|
||||
workMode.value = queries.get('work_mode')
|
||||
}
|
||||
updateJobs()
|
||||
})
|
||||
|
||||
@@ -145,6 +157,12 @@ const updateFilters = () => {
|
||||
delete filters.value.type
|
||||
}
|
||||
|
||||
if (workMode.value) {
|
||||
filters.value.work_mode = workMode.value
|
||||
} else {
|
||||
delete filters.value.work_mode
|
||||
}
|
||||
|
||||
if (searchQuery.value) {
|
||||
orFilters.value = {
|
||||
job_title: ['like', `%${searchQuery.value}%`],
|
||||
@@ -180,6 +198,15 @@ const jobTypes = computed(() => {
|
||||
]
|
||||
})
|
||||
|
||||
const workModes = computed(() => {
|
||||
return [
|
||||
'',
|
||||
{ label: 'On site', value: 'On-site' },
|
||||
{ label: 'Hybrid', value: 'Hybrid' },
|
||||
{ label: 'Remote', value: 'Remote' },
|
||||
]
|
||||
})
|
||||
|
||||
usePageMeta(() => {
|
||||
return {
|
||||
title: __('Jobs'),
|
||||
|
||||
718
frontend/src/pages/LeaderBoard.vue
Normal file
718
frontend/src/pages/LeaderBoard.vue
Normal file
@@ -0,0 +1,718 @@
|
||||
<template>
|
||||
<div class="lms-page-container">
|
||||
|
||||
<!-- HEADER & TABS -->
|
||||
<div class="lms-page-header">
|
||||
<h1 class="page-title">{{ __('Таблица лидеров') }}</h1>
|
||||
|
||||
<!-- Сегментированные вкладки (Apple / Frappe style) -->
|
||||
<div class="lms-tabs-container">
|
||||
<button
|
||||
v-for="group in roleGroups"
|
||||
:key="group.role"
|
||||
@click="activeGroup = group.role"
|
||||
class="lms-tab-btn"
|
||||
:class="{ 'active': activeGroup === group.role }"
|
||||
>
|
||||
{{ group.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MAIN GRID LAYOUT -->
|
||||
<div class="lms-layout-grid">
|
||||
|
||||
<!-- LEFT COLUMN: SUMMARY CARDS -->
|
||||
<div class="lms-sidebar">
|
||||
|
||||
<!-- Карточка: Ваш результат -->
|
||||
<div class="lms-card my-result-card">
|
||||
<div class="lms-card-body">
|
||||
<div class="card-header">
|
||||
<span class="card-subtitle">{{ __('Ваш результат') }}</span>
|
||||
<div v-if="currentUserPosition === 1" class="icon-gold"><i class="fas fa-crown"></i></div>
|
||||
<div v-else-if="currentUserPosition === 2" class="icon-silver"><i class="fas fa-medal"></i></div>
|
||||
<div v-else-if="currentUserPosition === 3" class="icon-bronze"><i class="fas fa-medal"></i></div>
|
||||
<div v-else class="icon-gray"><i class="fas fa-user"></i></div>
|
||||
</div>
|
||||
|
||||
<h2 class="card-title truncate-text" :title="currentUser.full_name">{{ currentUser.full_name || __('Вы') }}</h2>
|
||||
|
||||
<div class="card-stats">
|
||||
<div class="stat-block">
|
||||
<span class="stat-value">{{ currentUserPosition !== '-' ? currentUserPosition : '-' }}</span>
|
||||
<span class="stat-label">{{ __('Место') }}</span>
|
||||
</div>
|
||||
<div class="stat-block">
|
||||
<span class="stat-value text-primary">{{ currentUserPoints }}</span>
|
||||
<span class="stat-label">{{ __('Очки') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<p v-if="pointsToNext > 0 && currentUserPosition !== '-'" class="text-muted">
|
||||
{{ __('До') }} {{ nextPosition }}-{{ __('го места не хватает') }} <strong style="color: #111827;">{{ pointsToNext }}</strong> {{ __('очков') }}
|
||||
</p>
|
||||
<p v-else-if="currentUserPosition === 1" class="text-success">
|
||||
<i class="fas fa-check-circle"></i> {{ __('Вы на первом месте!') }}
|
||||
</p>
|
||||
<p v-else class="text-muted">{{ __('Выполняйте задания, чтобы попасть в топ') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Карточка: Лидер группы -->
|
||||
<div class="lms-card leader-card">
|
||||
<div class="lms-card-body">
|
||||
<div class="card-header">
|
||||
<span class="card-subtitle">{{ __('Лидер группы') }}</span>
|
||||
<div class="icon-gold"><i class="fas fa-trophy"></i></div>
|
||||
</div>
|
||||
|
||||
<template v-if="topUserInGroup">
|
||||
<h2 class="card-title truncate-text" :title="topUserInGroup.full_name">
|
||||
<a :href="`/lms/user/${topUserInGroup.username}`" class="card-link">
|
||||
{{ topUserInGroup.full_name }}
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<div class="card-stats">
|
||||
<div class="stat-block">
|
||||
<span class="stat-value">1</span>
|
||||
<span class="stat-label">{{ __('Место') }}</span>
|
||||
</div>
|
||||
<div class="stat-block">
|
||||
<span class="stat-value text-gold">{{ topUserInGroup.points }}</span>
|
||||
<span class="stat-label">{{ __('Очки') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<p class="text-muted">{{ __('Лучший результат среди категории') }} «{{ activeGroupLabel }}»</p>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<h2 class="card-title text-muted mt-2">{{ __('Пока нет лидера') }}</h2>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- RIGHT COLUMN: LEADERBOARD TABLE -->
|
||||
<div class="lms-main-content">
|
||||
<div class="lms-card table-card">
|
||||
<div class="lms-table-header">
|
||||
<h3>{{ activeGroupLabel }} <span class="count-badge">{{ currentLeaderboard.length }}</span></h3>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table v-if="currentLeaderboard.length > 0" class="lms-table">
|
||||
<!-- FIX: Fixed table layout to prevent jumping when tabs change -->
|
||||
<colgroup>
|
||||
<col style="width: 70px;">
|
||||
<col style="width: auto;">
|
||||
<col style="width: 130px;">
|
||||
<col style="width: 130px;">
|
||||
<col v-if="activeGroup === 'LMS Schoolchild'" style="width: 150px;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center;">#</th>
|
||||
<th>{{ __('Пользователь') }}</th>
|
||||
<th style="text-align: center;">{{ __('Активность') }}</th>
|
||||
<th style="text-align: center;">{{ __('Всего') }}</th>
|
||||
<th v-if="activeGroup === 'LMS Schoolchild'" style="text-align: center;">{{ __('Баллы МПГУ') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(user, index) in currentLeaderboard"
|
||||
:key="user.user"
|
||||
:class="{'is-current-user': user.user === currentUser.name}"
|
||||
>
|
||||
<!-- Ранг -->
|
||||
<td style="text-align: center; font-weight: 600; color: #4b5563;">
|
||||
<span v-if="index === 0" title="1 Место" class="medal-emoji">🥇</span>
|
||||
<span v-else-if="index === 1" title="2 Место" class="medal-emoji">🥈</span>
|
||||
<span v-else-if="index === 2" title="3 Место" class="medal-emoji">🥉</span>
|
||||
<span v-else>{{ index + 1 }}</span>
|
||||
</td>
|
||||
|
||||
<!-- Пользователь -->
|
||||
<td>
|
||||
<div class="user-cell">
|
||||
<div class="user-avatar">{{ getUserInitial(user) }}</div>
|
||||
<a :href="`/lms/user/${user.username}`" class="user-link truncate-text" :title="user.full_name">
|
||||
{{ user.full_name }}
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<!-- Очки -->
|
||||
<td style="text-align: center; font-weight: 600; color: #111827;">
|
||||
{{ user.points }}
|
||||
</td>
|
||||
<td style="text-align: center; font-weight: 600; color: #111827;">
|
||||
{{ user.points }}
|
||||
</td>
|
||||
|
||||
<!-- Бонусы МПГУ -->
|
||||
<td v-if="activeGroup === 'LMS Schoolchild'" style="text-align: center;">
|
||||
<span v-if="user.bonus > 0" class="bonus-badge">
|
||||
+{{ user.bonus }}
|
||||
</span>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div v-else class="lms-empty-state">
|
||||
<i class="fas fa-ghost empty-icon"></i>
|
||||
<p>{{ __('В этой категории пока нет участников.') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { usersStore } from '@/stores/user'
|
||||
import { createResource } from 'frappe-ui'
|
||||
|
||||
const store = usersStore()
|
||||
const { userResource, allUsers } = store
|
||||
|
||||
const roleGroups = [
|
||||
{ role: 'LMS Student', label: __('Студенты') },
|
||||
{ role: 'Course Creator', label: __('Преподаватели') },
|
||||
{ role: 'LMS Schoolchild', label: __('Школьники') }
|
||||
]
|
||||
|
||||
function getUserRoleGroup(userRoles) {
|
||||
if (!userRoles) return 'LMS Student'
|
||||
const validRole = userRoles.find(role =>
|
||||
roleGroups.some(group => group.role === role)
|
||||
)
|
||||
return validRole || 'LMS Student'
|
||||
}
|
||||
|
||||
const activeGroup = ref('LMS Student')
|
||||
|
||||
const usersList = computed(() => allUsers.data || [])
|
||||
|
||||
const logsResource = createResource({
|
||||
url: "frappe.client.get_list",
|
||||
params: {
|
||||
doctype: "Energy Point Log",
|
||||
fields: ["user", "points"],
|
||||
limit_page_length: 10000
|
||||
},
|
||||
auto: false,
|
||||
onError: (err) => console.error("Error loading Energy Point Log:", err)
|
||||
})
|
||||
|
||||
const leaderboard = ref([])
|
||||
|
||||
const currentUser = computed(() => {
|
||||
return userResource.data || {}
|
||||
})
|
||||
|
||||
const currentUserInitial = computed(() => {
|
||||
if (currentUser.value.full_name) {
|
||||
return currentUser.value.full_name.charAt(0).toUpperCase()
|
||||
}
|
||||
return currentUser.value.name?.charAt(0).toUpperCase() || 'U'
|
||||
})
|
||||
|
||||
function getUserInitial(user) {
|
||||
return user.full_name?.charAt(0).toUpperCase() || user.username?.charAt(0).toUpperCase() || 'U'
|
||||
}
|
||||
|
||||
watch(
|
||||
[() => logsResource.data, () => allUsers.data],
|
||||
() => {
|
||||
if (logsResource.data && allUsers.data) {
|
||||
calculateLeaderboard()
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
watch([currentUser, usersList], () => {
|
||||
if (currentUser.value.roles && usersList.value.length > 0) {
|
||||
const userGroup = getUserRoleGroup(currentUser.value.roles)
|
||||
activeGroup.value = userGroup
|
||||
}
|
||||
})
|
||||
|
||||
const activeGroupLabel = computed(() => {
|
||||
const group = roleGroups.find(g => g.role === activeGroup.value)
|
||||
return group ? group.label : ''
|
||||
})
|
||||
|
||||
const currentLeaderboard = computed(() => {
|
||||
return leaderboard.value
|
||||
.filter(user => user.roles.includes(activeGroup.value))
|
||||
.slice(0, 50)
|
||||
})
|
||||
|
||||
const topUserInGroup = computed(() => {
|
||||
return currentLeaderboard.value[0]
|
||||
})
|
||||
|
||||
const currentUserPosition = computed(() => {
|
||||
const userInLeaderboard = currentLeaderboard.value.findIndex(
|
||||
user => user.user === currentUser.value.name
|
||||
)
|
||||
return userInLeaderboard !== -1 ? userInLeaderboard + 1 : '-'
|
||||
})
|
||||
|
||||
const currentUserPoints = computed(() => {
|
||||
const userEntry = leaderboard.value.find(user => user.user === currentUser.value.name)
|
||||
return userEntry ? userEntry.points : 0
|
||||
})
|
||||
|
||||
const pointsToNext = computed(() => {
|
||||
const userIndex = currentLeaderboard.value.findIndex(
|
||||
user => user.user === currentUser.value.name
|
||||
)
|
||||
if (userIndex === -1 || userIndex === 0) return 0
|
||||
const currentPoints = currentLeaderboard.value[userIndex].points
|
||||
const nextUserPoints = currentLeaderboard.value[userIndex - 1].points
|
||||
return nextUserPoints - currentPoints + 1
|
||||
})
|
||||
|
||||
const nextPosition = computed(() => {
|
||||
const userIndex = currentLeaderboard.value.findIndex(
|
||||
user => user.user === currentUser.value.name
|
||||
)
|
||||
return userIndex > 0 ? userIndex : 1
|
||||
})
|
||||
|
||||
function calculateLeaderboard() {
|
||||
if (!logsResource.data || !usersList.value) return
|
||||
|
||||
const pointsMap = {}
|
||||
|
||||
logsResource.data.forEach(log => {
|
||||
if (!pointsMap[log.user]) pointsMap[log.user] = 0
|
||||
pointsMap[log.user] += log.points
|
||||
})
|
||||
|
||||
leaderboard.value = Object.keys(pointsMap)
|
||||
.map(user => {
|
||||
const u = usersList.value.find(x => x.name === user)
|
||||
if (!u) return null
|
||||
|
||||
const hasValidRole = u.roles && u.roles.some(role =>
|
||||
roleGroups.some(group => group.role === role)
|
||||
)
|
||||
|
||||
if (!hasValidRole) return null
|
||||
if (pointsMap[user] < 0) return null
|
||||
|
||||
const isSchoolchild = u.roles.includes('LMS Schoolchild')
|
||||
const bonus = isSchoolchild ? Math.min(Math.floor(pointsMap[user] / 100), 10) : 0
|
||||
|
||||
return {
|
||||
user,
|
||||
points: pointsMap[user],
|
||||
full_name: u.full_name,
|
||||
username: u.username,
|
||||
roles: u.roles || [],
|
||||
bonus: bonus,
|
||||
isSchoolchild: isSchoolchild
|
||||
}
|
||||
})
|
||||
.filter(user => user !== null)
|
||||
.sort((a, b) => b.points - a.points)
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await allUsers.reload()
|
||||
await logsResource.reload()
|
||||
calculateLeaderboard()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* ============================================
|
||||
ДИЗАЙН В СТИЛЕ FRAPPE LMS
|
||||
============================================ */
|
||||
|
||||
.lms-page-container {
|
||||
padding: 32px;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
/* === HEADER & TABS === */
|
||||
.lms-page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 32px;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: #111827;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.lms-tabs-container {
|
||||
display: inline-flex;
|
||||
background-color: #f3f4f6;
|
||||
padding: 4px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.lms-tab-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #6b7280;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
padding: 8px 20px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.lms-tab-btn:hover {
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.lms-tab-btn.active {
|
||||
background: #ffffff;
|
||||
color: #111827;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* === MAIN GRID LAYOUT === */
|
||||
.lms-layout-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 340px 1fr;
|
||||
gap: 24px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.lms-sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
/* === CARDS === */
|
||||
.lms-card {
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lms-card-body {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card-subtitle {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.icon-gold { color: #f59e0b; font-size: 1.4rem; }
|
||||
.icon-silver { color: #9ca3af; font-size: 1.4rem; }
|
||||
.icon-bronze { color: #b45309; font-size: 1.4rem; }
|
||||
.icon-gray { color: #d1d5db; font-size: 1.4rem; }
|
||||
|
||||
.card-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 24px 0;
|
||||
color: #111827;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.card-link {
|
||||
text-decoration: none;
|
||||
color: #111827;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
.card-link:hover { color: #00a9a6; }
|
||||
|
||||
.card-stats {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
margin-top: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-primary { color: #00a9a6; }
|
||||
.text-gold { color: #f59e0b; }
|
||||
.text-muted { color: #6b7280; font-size: 13px; margin: 0; line-height: 1.5; }
|
||||
.text-success { color: #059669; font-size: 13px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 6px; }
|
||||
|
||||
.card-footer {
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
/* === TABLE === */
|
||||
.table-card {
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
.lms-table-header {
|
||||
padding: 20px 24px;
|
||||
background: #ffffff;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.lms-table-header h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.count-badge {
|
||||
background: #f3f4f6;
|
||||
color: #4b5563;
|
||||
padding: 2px 10px;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* --- FIX: Настройки скролла для длинной таблицы --- */
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
max-height: 650px; /* Ограничиваем высоту, чтобы таблица не уезжала вниз */
|
||||
}
|
||||
|
||||
/* Кастомный красивый скроллбар */
|
||||
.table-responsive::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
.table-responsive::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
.table-responsive::-webkit-scrollbar-thumb {
|
||||
background-color: #d1d5db;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.table-responsive::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #9ca3af;
|
||||
}
|
||||
|
||||
.lms-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.lms-table th {
|
||||
background: #f9fafb;
|
||||
color: #4b5563;
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
padding: 14px 24px;
|
||||
/* Заменяем border-bottom на box-shadow для sticky, чтобы не было просветов */
|
||||
box-shadow: inset 0 -1px 0 #e5e7eb;
|
||||
white-space: nowrap;
|
||||
/* Делаем шапку прилипающей */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.lms-table td {
|
||||
padding: 16px 24px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
color: #374151;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.lms-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.lms-table tr:hover {
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
|
||||
.lms-table tr.is-current-user {
|
||||
background-color: #f0fdfa;
|
||||
}
|
||||
.lms-table tr.is-current-user td {
|
||||
border-bottom-color: #ccfbf1;
|
||||
}
|
||||
|
||||
.medal-emoji {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.user-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: #e5e7eb;
|
||||
color: #4b5563;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.is-current-user .user-avatar {
|
||||
background: #00a9a6;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user-link {
|
||||
color: #111827;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
.user-link:hover {
|
||||
color: #00a9a6;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.truncate-text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.bonus-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
background: #ecfdf5;
|
||||
color: #059669;
|
||||
padding: 4px 10px;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.lms-empty-state {
|
||||
padding: 60px 20px;
|
||||
text-align: center;
|
||||
color: #6b7280;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 32px;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
/* === RESPONSIVE === */
|
||||
@media (max-width: 1024px) {
|
||||
.lms-layout-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.lms-sidebar {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.lms-card {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.lms-page-container {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.lms-sidebar {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.lms-tabs-container {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.lms-tab-btn {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.lms-table th, .lms-table td {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
/* Немного уменьшим высоту на мобилках */
|
||||
.table-responsive {
|
||||
max-height: 500px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -258,6 +258,7 @@
|
||||
v-if="lesson.data?.body"
|
||||
:content="lesson.data.body"
|
||||
:youtube="lesson.data.youtube"
|
||||
:rutube="lesson.data.rutube"
|
||||
:quizId="lesson.data.quiz_id"
|
||||
/>
|
||||
</div>
|
||||
@@ -733,7 +734,7 @@ const updateVideoTime = (video) => {
|
||||
const startTimer = () => {
|
||||
let timerInterval = setInterval(() => {
|
||||
timer.value++
|
||||
if (timer.value == 30) {
|
||||
if (timer.value == 5) {
|
||||
clearInterval(timerInterval)
|
||||
markProgress()
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
<div class="w-5/6 mx-auto">
|
||||
<FormControl
|
||||
v-model="lesson.title"
|
||||
label="Title"
|
||||
:label="__('Title')"
|
||||
class="mb-4"
|
||||
:required="true"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="lesson.include_in_preview"
|
||||
type="checkbox"
|
||||
label="Include in Preview"
|
||||
:label="__('Include in Preview')"
|
||||
/>
|
||||
</div>
|
||||
<div class="border-t mt-4">
|
||||
@@ -142,7 +142,6 @@ const renderEditor = (holder) => {
|
||||
return new EditorJS({
|
||||
holder: holder,
|
||||
tools: getEditorTools(true),
|
||||
autofocus: true,
|
||||
defaultBlock: 'markdown',
|
||||
onChange: async (api, event) => {
|
||||
enablePlyr()
|
||||
@@ -273,6 +272,7 @@ const lessonReference = createResource({
|
||||
|
||||
const convertToJSON = (lessonData) => {
|
||||
let blocks = []
|
||||
|
||||
if (lessonData.youtube) {
|
||||
let youtubeID = lessonData.youtube.split('/').pop()
|
||||
blocks.push({
|
||||
@@ -283,6 +283,20 @@ const convertToJSON = (lessonData) => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if (lessonData.rutube) {
|
||||
let rutubeID = lessonData.rutube.includes('rutube.ru')
|
||||
? lessonData.rutube.split('/').pop()
|
||||
: lessonData.rutube;
|
||||
blocks.push({
|
||||
type: 'embed',
|
||||
data: {
|
||||
service: 'rutube',
|
||||
embed: `https://rutube.ru/play/embed/${rutubeID}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
lessonData.body.split('\n').forEach((block) => {
|
||||
if (block.includes('{{ YouTubeVideo')) {
|
||||
let youtubeID = block.match(/\(["']([^"']+?)["']\)/)[1]
|
||||
@@ -295,6 +309,18 @@ const convertToJSON = (lessonData) => {
|
||||
embed: youtubeID,
|
||||
},
|
||||
})
|
||||
} else if (block.includes('{{ RutubeVideo')) {
|
||||
let rutubeID = block.match(/\(["']([^"']+?)["']\)/)[1];
|
||||
if (rutubeID.includes('rutube.ru')) {
|
||||
rutubeID = rutubeID.split('/').pop();
|
||||
}
|
||||
blocks.push({
|
||||
type: 'embed',
|
||||
data: {
|
||||
service: 'rutube',
|
||||
embed: `https://rutube.ru/play/embed/${rutubeID}`,
|
||||
},
|
||||
});
|
||||
} else if (block.includes('{{ Quiz')) {
|
||||
let quiz = block.match(/\(["']([^"']+?)["']\)/)[1]
|
||||
blocks.push({
|
||||
@@ -459,17 +485,17 @@ const editCurrentLesson = () => {
|
||||
|
||||
const validateLesson = () => {
|
||||
if (!lesson.title) {
|
||||
return 'Title is required'
|
||||
return __('Title is required')
|
||||
}
|
||||
if (!lesson.content) {
|
||||
return 'Content is required'
|
||||
return __('Content is required')
|
||||
}
|
||||
}
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
let crumbs = [
|
||||
{
|
||||
label: 'Courses',
|
||||
label: __('Courses'),
|
||||
route: { name: 'Courses' },
|
||||
},
|
||||
{
|
||||
@@ -480,7 +506,7 @@ const breadcrumbs = computed(() => {
|
||||
|
||||
if (lessonDetails?.data?.lesson) {
|
||||
crumbs.push({
|
||||
label: lessonDetails.data.lesson.title,
|
||||
label: __(lessonDetails.data.lesson.title),
|
||||
route: {
|
||||
name: 'Lesson',
|
||||
params: {
|
||||
@@ -492,7 +518,7 @@ const breadcrumbs = computed(() => {
|
||||
})
|
||||
}
|
||||
crumbs.push({
|
||||
label: lessonDetails?.data?.lesson ? 'Edit Lesson' : 'Create Lesson',
|
||||
label: lessonDetails?.data?.lesson ? __('Edit Lesson') : __('Create Lesson'),
|
||||
route: {
|
||||
name: 'LessonForm',
|
||||
params: {
|
||||
@@ -508,8 +534,8 @@ const breadcrumbs = computed(() => {
|
||||
usePageMeta(() => {
|
||||
return {
|
||||
title: lessonDetails?.data?.lesson
|
||||
? lessonDetails.data.lesson.title
|
||||
: 'New Lesson',
|
||||
? __(lessonDetails.data.lesson.title)
|
||||
: __('New Lesson'),
|
||||
icon: brand.favicon,
|
||||
}
|
||||
})
|
||||
|
||||
183
frontend/src/pages/MyPoints.vue
Normal file
183
frontend/src/pages/MyPoints.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<div v-if="!$user.data">
|
||||
<NoPermission />
|
||||
</div>
|
||||
|
||||
<div v-else class="min-h-screen bg-50">
|
||||
<header class="sticky top-0 z-10 flex items-center justify-between border-b bg-surface-white px-5 py-3">
|
||||
<Breadcrumbs :items="breadcrumbs" />
|
||||
</header>
|
||||
|
||||
<div class="p-5 pb-10">
|
||||
<h2 class="text-lg text-ink-gray-9 font-semibold">{{__('My points')}}</h2>
|
||||
|
||||
<!-- Загрузка -->
|
||||
<div v-if="energyPoints.loading" class="text-center py-16 text-gray-600">
|
||||
{{__('Loading points...')}}
|
||||
</div>
|
||||
|
||||
<!-- Нет баллов -->
|
||||
<div v-else-if="!energyPoints.data?.length" class="bg-white rounded-xl shadow-xl mt-4 p-12 text-center">
|
||||
<p class="text-xl text-gray-800">{{__('You don`t have any points yet')}}</p>
|
||||
<p class="text-sm text-gray-700 mt-2">{{__('Participate in the activities — the points will appear!')}}</p>
|
||||
</div>
|
||||
|
||||
<!-- Есть баллы -->
|
||||
<div v-else>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
|
||||
<!-- ЛЕВАЯ КОЛОНКА — список баллов -->
|
||||
<div class="bg-white rounded-xl shadow-xl mt-4">
|
||||
<ul class="divide-y divide-gray-200">
|
||||
<li v-for="item in visibleItems" :key="item.name" class="p-6 hover:bg-gray-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-5">
|
||||
<div class="text-2xl font-bold"
|
||||
:class="item.points > 0 ? 'text-green-600' : 'text-red-600'">
|
||||
{{ item.points > 0 ? '+' : '' }}{{ item.points }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p class="font-medium text-gray-900">
|
||||
{{__( item.rule || 'Accrual of points' )}}
|
||||
</p>
|
||||
<p class="text-sm text-gray-500">
|
||||
{{ dayjs(item.creation).format('DD MMMM YYYY в HH:mm') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-if="!showAll && energyPoints.data.length > 5" class="p-6 text-center">
|
||||
<button
|
||||
@click="showAll = true"
|
||||
class="px-4 py-2 bg-gray-2 text-gray rounded-lg shadow-xl hover:bg-gray-3 transition">
|
||||
{{__('Load more')}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ПРАВАЯ КОЛОНКА — итоги -->
|
||||
<div class="space-y-6 text-teal-900">
|
||||
<!-- БЛОК "Ты сегодня получил баллы" -->
|
||||
<div class="bg-teal-600/20 rounded-xl p-6 shadow-xl mt-4">
|
||||
<p class="text-lg opacity-80">{{__('Your stats')}}</p>
|
||||
<p class="text-sm opacity-80 mt-1">
|
||||
{{__('You`ve earned a lot today:')}}<strong>{{ todayPoints }}</strong>
|
||||
</p>
|
||||
<p class="text-sm opacity-80 mt-3">
|
||||
{{ todayPoints > 0 ? __('Keep it up !') : __('You need to work out a little!') }}
|
||||
</p>
|
||||
<p class="text-sm opacity-80 mt-3">
|
||||
{{ differencePoints > 0 ? `${__('This is')} ${differencePoints} ${__('more than yesterday')}`
|
||||
: differencePoints < 0 ? `${__('This is')} ${Math.abs(differencePoints)} ${__('less than yesterday')}`
|
||||
: __('This is the same as yesterday') }}
|
||||
</p>
|
||||
<p class="text-sm opacity-80 mt-3">
|
||||
{{__('You`ve earned a lot in the last week:')}}<strong>{{ weeklyPoints }}</strong>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-teal-600/30 rounded-xl p-6 shadow-xl mt-4">
|
||||
<p class="text-lg opacity-80">{{__('Total points')}}</p>
|
||||
<p class="text-5xl font-bold mt-3">{{ totalPoints }}</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-teal-600/40 rounded-xl p-6 shadow-xl mt-4">
|
||||
<p class="text-lg font-semibold opacity-90">{{__('Additionally, upon admission to the MPSU')}}</p>
|
||||
<p class="text-5xl font-bold mt-3">+{{ additionalPoints }}</p>
|
||||
<p class="text-sm opacity-70 mt-3">{{__('maximum of 10 points')}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject, computed, onMounted, ref } from 'vue'
|
||||
import { createResource, Breadcrumbs } from 'frappe-ui'
|
||||
import NoPermission from '@/components/NoPermission.vue'
|
||||
|
||||
const $user = inject('$user')
|
||||
const dayjs = inject('$dayjs')
|
||||
|
||||
// Главное — фильтруем по email, как в LMS!
|
||||
const energyPoints = createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'Energy Point Log',
|
||||
fields: ['name', 'points', 'rule', 'creation'],
|
||||
filters: {
|
||||
user: $user.data.email // ← вот так, как в LMS — по email!
|
||||
},
|
||||
order_by: 'creation desc',
|
||||
limit_page_length: 1000
|
||||
},
|
||||
auto: false,
|
||||
onSuccess(data) {
|
||||
console.log('Баллы загружены:', data.length, 'записей')
|
||||
}
|
||||
})
|
||||
|
||||
const totalPoints = computed(() => {
|
||||
const list = Array.isArray(energyPoints.data) ? energyPoints.data : []
|
||||
return list.reduce((sum, item) => sum + (item.points || 0), 0)
|
||||
})
|
||||
|
||||
const additionalPoints = computed(() => {
|
||||
const bonus = Math.floor(totalPoints.value / 100)
|
||||
return bonus < 10 ? bonus : 10
|
||||
})
|
||||
|
||||
const breadcrumbs = computed(() => [
|
||||
{ label: __('Home'), route: '/' },
|
||||
{ label: __('My Points') }
|
||||
])
|
||||
|
||||
const showAll = ref(false)
|
||||
|
||||
const visibleItems = computed(() => {
|
||||
if (!Array.isArray(energyPoints.data)) return []
|
||||
return showAll.value
|
||||
? energyPoints.data // показать все
|
||||
: energyPoints.data.slice(0, 5) // первые 5
|
||||
})
|
||||
|
||||
function getPointsByDate(dateString) {
|
||||
if (!Array.isArray(energyPoints.data)) return 0
|
||||
|
||||
return energyPoints.data
|
||||
.filter(item => dayjs(item.creation).format('YYYY-MM-DD') === dateString)
|
||||
.reduce((sum, item) => sum + (item.points || 0), 0)
|
||||
}
|
||||
|
||||
const today = dayjs().format('YYYY-MM-DD')
|
||||
const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
|
||||
|
||||
const todayPoints = computed(() => getPointsByDate(today))
|
||||
const yesterdayPoints = computed(() => getPointsByDate(yesterday))
|
||||
|
||||
const differencePoints = computed(() =>
|
||||
todayPoints.value - yesterdayPoints.value
|
||||
)
|
||||
|
||||
const weeklyPoints = computed(() => {
|
||||
if (!Array.isArray(energyPoints.data)) return 0
|
||||
|
||||
const weekAgo = dayjs().subtract(7, 'day').startOf('day')
|
||||
|
||||
return energyPoints.data
|
||||
.filter(item => dayjs(item.creation).isAfter(weekAgo))
|
||||
.reduce((sum, item) => sum + (item.points || 0), 0)
|
||||
})
|
||||
onMounted(() => {
|
||||
if ($user.data) {
|
||||
energyPoints.fetch()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
762
frontend/src/pages/ParentProfile.vue
Normal file
762
frontend/src/pages/ParentProfile.vue
Normal file
@@ -0,0 +1,762 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-white">
|
||||
<NoPermission v-if="!$user.data" />
|
||||
|
||||
<div v-else-if="profile.error" class="p-6">
|
||||
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-sm p-6 border border-red-200">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки профиля: {{ profile.error.message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="profile.data">
|
||||
<header class="sticky top-0 z-10 flex items-center justify-between bg-white px-6 py-4">
|
||||
<Breadcrumbs class="h-7" :items="breadcrumbs" />
|
||||
</header>
|
||||
|
||||
<div class="mx-auto max-w-6xl px-4 py-6">
|
||||
<!-- Profile Header -->
|
||||
<div v-if="!schoolProfileNotFound" class="bg-gradient-to-r from-teal-100 to-teal-600 rounded-2xl shadow-sm border border-gray-200 p-6 -mt-4 relative">
|
||||
<div class="flex flex-col md:flex-row md:items-center gap-6">
|
||||
<div class="flex-1">
|
||||
<h2 class="text-3xl font-bold text-gray-900">{{ displayName }}</h2>
|
||||
<div
|
||||
v-if="profile.data.headline"
|
||||
v-html="
|
||||
DOMPurify.sanitize(decodeEntities(profile.data.headline), {
|
||||
ALLOWED_TAGS: [
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'a',
|
||||
'p',
|
||||
'br',
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
'img',
|
||||
],
|
||||
ALLOWED_ATTR: ['href', 'target', 'rel', 'src'],
|
||||
})
|
||||
"
|
||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-outline-gray-2 prose-th:border-outline-gray-2 prose-td:relative prose-th:relative prose-th:bg-surface-gray-2 prose-sm max-w-none !whitespace-normal mt-2 text-gray-700"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div v-if="$user.data && isSessionUser()" class="md:ml-auto">
|
||||
<Button @click="toggleEdit()" class="bg-white hover:bg-gray-100 px-5 py-2.5 rounded-lg transition-colors duration-200">
|
||||
<template #prefix>
|
||||
<Edit class="w-4 h-4 stroke-1.5" />
|
||||
</template>
|
||||
{{ editMode ? 'Отменить редактирование' : 'Редактировать профиль' }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VIEW MODE -->
|
||||
<div v-if="!editMode" class="mt-6">
|
||||
<!-- Пустой профиль родителя -->
|
||||
<div v-if="schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="p-8 text-center">
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="mx-auto w-20 h-20 bg-teal-100 rounded-full flex items-center justify-center mb-6">
|
||||
<svg class="w-10 h-10 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h3 class="text-2xl font-bold text-gray-900 mb-3">Профиль родителя еще не заполнен</h3>
|
||||
|
||||
<p class="text-gray-600 mb-6">
|
||||
Чтобы лучше понимать потребности вашего ребёнка и получать персонализированные рекомендации,
|
||||
заполните информацию о себе и своём ребёнке.
|
||||
</p>
|
||||
|
||||
<div class="bg-teal-50 border border-teal-100 rounded-lg p-5 mb-6 text-left">
|
||||
<h4 class="font-semibold text-teal-800 mb-3 flex items-center gap-2">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Заполнив профиль, вы сможете:
|
||||
</h4>
|
||||
<ul class="space-y-2 text-sm text-gray-700">
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Получать персонализированные рекомендации для развития ребёнка</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Находить подходящих наставников для вашего ребёнка</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Быть в курсе успехов и прогресса вашего ребёнка</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@click="toggleEdit()"
|
||||
class="bg-teal-600 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 shadow-sm hover:shadow-md"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
||||
</svg>
|
||||
</template>
|
||||
Заполнить профиль родителя
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загружающийся профиль -->
|
||||
<div v-else-if="schoolProfile.loading" class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ошибка загрузки (кроме DoesNotExistError) -->
|
||||
<div v-else-if="schoolProfile.error && !schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-red-200 p-6">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки данных родителя: {{ schoolProfile.error.message }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Загруженный профиль родителя -->
|
||||
<div v-else-if="schoolProfile.data && !schoolProfileNotFound" class="space-y-6">
|
||||
<!-- Основная информация -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Личная информация</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Фамилия:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.last_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Имя:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.first_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Отчество:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.middle_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Дата рождения:</span>
|
||||
<span class="text-gray-900">{{ formattedDate(schoolProfile.data.birth_date) || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Телефон:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.phone) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Email:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.email_private) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Telegram:</span>
|
||||
<div class="flex-1">
|
||||
<a v-if="schoolProfile.data.telegram"
|
||||
:href="formatTelegram(schoolProfile.data.telegram)"
|
||||
target="_blank"
|
||||
class="inline-flex items-center gap-2 text-primary-600 hover:text-primary-700 font-medium transition-colors">
|
||||
<span>{{ schoolProfile.data.telegram.replace('@', '') }}</span>
|
||||
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69.01-.03.01-.14-.06-.2-.07-.06-.17-.04-.24-.02-.1.02-1.69 1.09-4.78 3.2-.45.31-.86.46-1.23.45-.41-.01-1.2-.23-1.79-.42-.72-.23-1.29-.36-1.24-.76.03-.24.37-.48 1.01-.74 3.97-1.67 6.62-2.77 7.94-3.31 3.26-1.33 3.94-1.56 4.38-1.56.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<span v-else class="text-gray-500">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Информация о ребенке -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Информация о ребёнке</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">ФИО ребёнка:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.child_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Телефон ребёнка:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.child_phone) || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Email ребёнка:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.child_email) || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Цели для ребёнка:</span>
|
||||
<div class="flex-1">
|
||||
<div class="p-4 bg-teal-50 rounded-lg border border-teal-100">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.goals || 'Цели не указаны' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="text-center py-12">
|
||||
<div class="mx-auto w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4">
|
||||
<svg class="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5 6.197h-6"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-semibold text-gray-900 mb-2">Данные профиля не найдены</h3>
|
||||
<p class="text-gray-600">Информация о родителе отсутствует</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EDIT MODE -->
|
||||
<div v-else class="mt-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Редактирование профиля родителя</h3>
|
||||
<p class="text-sm text-gray-200 mt-1">Заполните информацию о себе и своём ребёнке</p>
|
||||
</div>
|
||||
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Левая колонка - Личная информация -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Личная информация</h4>
|
||||
|
||||
<Input
|
||||
v-model="form.last_name"
|
||||
label="Фамилия"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.first_name"
|
||||
label="Имя"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.middle_name"
|
||||
label="Отчество"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Дата рождения</label>
|
||||
<DatePicker
|
||||
v-model="form.birth_date"
|
||||
class="w-full bg-gray-50 border-gray-300 rounded-lg focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-model="form.phone"
|
||||
label="Телефон (не публиковать)"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.email_private"
|
||||
label="Email (не публиковать)"
|
||||
type="email"
|
||||
placeholder="example@email.com"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.telegram"
|
||||
label="Telegram"
|
||||
placeholder="username или t.me/username"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Правая колонка - Информация о ребенке -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Информация о ребёнке</h4>
|
||||
|
||||
<Input
|
||||
v-model="form.child_name"
|
||||
label="ФИО ребёнка"
|
||||
placeholder="Иванов Иван Иванович"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.child_phone"
|
||||
label="Телефон ребёнка"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.child_email"
|
||||
label="Email ребёнка"
|
||||
type="email"
|
||||
placeholder="child@email.com"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
v-model="form.goals"
|
||||
label="Какие цели Вы ставите своему ребёнку?"
|
||||
rows="6"
|
||||
placeholder="Опишите ваши ожидания и цели для развития вашего ребёнка..."
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="mt-8 pt-6 border-t border-gray-200 flex gap-3">
|
||||
<Button
|
||||
@click="saveProfile"
|
||||
:loading="saving"
|
||||
class="bg-teal-400 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 flex items-center gap-2"
|
||||
>
|
||||
{{ saving ? 'Сохранение...' : 'Сохранить изменения' }}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
@click="toggleEdit()"
|
||||
class="border-gray-300 text-gray-700 hover:bg-gray-50 px-6 py-3 rounded-lg font-medium transition-colors duration-200"
|
||||
>
|
||||
Отмена
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex items-center justify-center min-h-screen">
|
||||
<div class="text-center">
|
||||
<div class="animate-spin rounded-full h-16 w-16 border-b-2 border-primary-600 mx-auto"></div>
|
||||
<p class="mt-4 text-lg text-gray-600">Загрузка профиля...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Плавные переходы для интерактивных элементов */
|
||||
.border-gray-300 {
|
||||
transition: border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.bg-primary-50 {
|
||||
background-color: rgba(59, 130, 246, 0.05);
|
||||
}
|
||||
|
||||
/* Стилизация скроллбара для выпадающих списков */
|
||||
.overflow-y-auto::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
|
||||
background: #a1a1a1;
|
||||
}
|
||||
|
||||
/* Анимация для кнопок */
|
||||
.transition-colors {
|
||||
transition-property: background-color, border-color, color, fill, stroke;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 200ms;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Скрипт остается без изменений, только нужно добавить импорты -->
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject, watch, onMounted } from 'vue';
|
||||
import { Breadcrumbs, createResource, Button, Input, DatePicker, Select, Textarea } from 'frappe-ui';
|
||||
import { sessionStore } from '@/stores/session';
|
||||
import NoPermission from '@/components/NoPermission.vue';
|
||||
import { Edit } from 'lucide-vue-next';
|
||||
import { convertToTitleCase, updateDocumentTitle } from '@/utils';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { decodeEntities } from '@/utils'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
const { user } = sessionStore();
|
||||
const $user = inject('$user');
|
||||
const schoolProfileNotFound = ref(false);
|
||||
|
||||
// Логирование инициализации
|
||||
console.log('[DEBUG] Инициализация компонента:', {
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
username: $user.data?.username,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
username: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const effectiveUsername = computed(() => {
|
||||
const username = props.username || $user.data?.username || '';
|
||||
console.log('[DEBUG] Вычисление effectiveUsername:', { propsUsername: props.username, sessionUsername: $user.data?.username, result: username });
|
||||
return username;
|
||||
});
|
||||
|
||||
const editMode = ref(false);
|
||||
const saving = ref(false);
|
||||
|
||||
const profile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
makeParams(values) {
|
||||
const username = effectiveUsername.value;
|
||||
console.log('[DEBUG] Запрос profile:', { doctype: 'User', filters: { username } });
|
||||
return {
|
||||
doctype: 'User',
|
||||
filters: { username },
|
||||
};
|
||||
},
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль пользователя: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const schoolProfile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user:user },
|
||||
},
|
||||
auto: false,
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль школьника загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
// Проверяем, является ли ошибка "не найдено"
|
||||
if (error.exc_type === 'DoesNotExistError' || error.message?.includes('DoesNotExist')) {
|
||||
console.log('[DEBUG] Профиль родителя не найден, создаем новый');
|
||||
schoolProfileNotFound.value = true;
|
||||
} else {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля родителя:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль родителя: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const form = ref({
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
middle_name: '',
|
||||
birth_date: '',
|
||||
phone: '',
|
||||
email_private: '',
|
||||
telegram: '',
|
||||
child_name: '',
|
||||
child_phone: '',
|
||||
child_email: '',
|
||||
goals: '',
|
||||
|
||||
});
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
const username = effectiveUsername.value;
|
||||
const crumbs = [
|
||||
{
|
||||
label: 'People',
|
||||
route: { name: 'People' },
|
||||
},
|
||||
{
|
||||
label: profile.data?.full_name || 'Профиль',
|
||||
route: username ? {
|
||||
name: 'Profile',
|
||||
params: { username },
|
||||
} : undefined,
|
||||
},
|
||||
];
|
||||
console.log('[DEBUG] Хлебные крошки:', crumbs);
|
||||
return crumbs;
|
||||
});
|
||||
|
||||
const pageMeta = computed(() => {
|
||||
const meta = {
|
||||
title: profile.data?.full_name || 'Профиль',
|
||||
description: profile.data?.headline || '',
|
||||
};
|
||||
console.log('[DEBUG] Мета-данные страницы:', meta);
|
||||
return meta;
|
||||
});
|
||||
|
||||
const displayName = computed(() => {
|
||||
if (!profile.data) {
|
||||
console.log('[DEBUG] displayName: profile.data не загружен');
|
||||
return 'Загрузка...';
|
||||
}
|
||||
const name = profile.data?.full_name || `${form.value.first_name || ''} ${form.value.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Отображаемое имя:', name);
|
||||
return name;
|
||||
});
|
||||
|
||||
const isSessionUser = () => {
|
||||
const sessionUser = $user.data?.username;
|
||||
const profileUser = effectiveUsername.value;
|
||||
const isSession = sessionUser === profileUser;
|
||||
console.log('[DEBUG] Проверка isSessionUser:', { sessionUser, profileUser, isSession });
|
||||
return isSession;
|
||||
};
|
||||
|
||||
function formattedDate(d) {
|
||||
if (!d) return '';
|
||||
try {
|
||||
return new Date(d).toLocaleDateString('ru-RU');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка форматирования даты:', e, { date: d });
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
function maskPrivate(val) {
|
||||
if (!val) return '-';
|
||||
if (val.includes('@')) {
|
||||
const parts = val.split('@');
|
||||
return parts[0].slice(0, 1) + '***@' + parts[1];
|
||||
}
|
||||
return val.slice(0, 3) + '***' + val.slice(-2);
|
||||
}
|
||||
|
||||
function formatTelegram(t) {
|
||||
if (!t) return '';
|
||||
if (t.startsWith('t.me/') || t.startsWith('https://t.me/')) return (t.startsWith('http') ? t : 'https://' + t);
|
||||
return 'https://t.me/' + t.replace(/^@/, '');
|
||||
}
|
||||
|
||||
function fillFormFromProfile() {
|
||||
console.log('[DEBUG] Заполнение формы:', {
|
||||
schoolProfile: schoolProfile.data,
|
||||
profile: profile.data,
|
||||
currentForm: JSON.stringify(form.value, null, 2),
|
||||
});
|
||||
form.value.first_name = schoolProfile.data?.first_name || profile.data?.first_name || '';
|
||||
form.value.last_name = schoolProfile.data?.last_name || profile.data?.last_name || '';
|
||||
form.value.middle_name = schoolProfile.data?.middle_name || '';
|
||||
form.value.birth_date = schoolProfile.data?.birth_date || '';
|
||||
form.value.phone = schoolProfile.data?.phone || '';
|
||||
form.value.email_private = schoolProfile.data?.email_private || '';
|
||||
form.value.telegram = schoolProfile.data?.telegram || '';
|
||||
form.value.child_name = schoolProfile.data?.child_name || '';
|
||||
form.value.child_phone = schoolProfile.data?.child_phone || '';
|
||||
form.value.child_email = schoolProfile.data?.child_email || '';
|
||||
form.value.goals = schoolProfile.data?.goals || '';
|
||||
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
|
||||
function toggleEdit() {
|
||||
editMode.value = !editMode.value;
|
||||
if (editMode.value) fillFormFromProfile();
|
||||
console.log('[DEBUG] Переключение режима редактирования:', { editMode: editMode.value });
|
||||
}
|
||||
|
||||
function validateExams(exams) {
|
||||
console.log('[DEBUG] Валидация exams:', { exams, validOptions: examOptions });
|
||||
return exams.every(exam => examOptions.includes(exam));
|
||||
}
|
||||
|
||||
function validateLearnSubjects(subjects) {
|
||||
console.log('[DEBUG] Валидация learn_subjects:', { subjects, validOptions: learnOptions });
|
||||
return subjects.every(subject => learnOptions.includes(subject));
|
||||
}
|
||||
|
||||
async function saveProfile() {
|
||||
console.log('[DEBUG] Сохранение профиля:', { form: form.value });
|
||||
saving.value = true;
|
||||
try {
|
||||
// Создаём копию данных формы
|
||||
const formData = { ...form.value };
|
||||
console.log('[DEBUG] Копия formData:', JSON.stringify(formData, null, 2));
|
||||
|
||||
// Обновление full_name в User, если нужно
|
||||
if (formData.first_name || formData.last_name) {
|
||||
const fullName = `${formData.first_name || ''} ${formData.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Обновление User.full_name:', { name: profile.data?.name, fullName });
|
||||
await createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
params: {
|
||||
doctype: 'User',
|
||||
name: profile.data?.name,
|
||||
fieldname: 'full_name',
|
||||
value: fullName,
|
||||
},
|
||||
}).submit();
|
||||
}
|
||||
|
||||
// Получаем docname
|
||||
let docname = '';
|
||||
try {
|
||||
await schoolProfile.reload();
|
||||
console.log('[DEBUG] Schoolprofile:', { schoolProfile });
|
||||
docname = schoolProfile?.data?.name;
|
||||
console.log('[DEBUG] Выбранное имя документа:', docname);
|
||||
} catch (error) {
|
||||
console.log('[DEBUG] Ошибка загрузки schoolProfile, продолжаем с profile:', error.message);
|
||||
}
|
||||
|
||||
// Формируем payload из копии данных формы
|
||||
let payload = {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
user: profile.data?.name,
|
||||
first_name: formData.first_name,
|
||||
last_name: formData.last_name,
|
||||
middle_name: formData.middle_name,
|
||||
birth_date: formData.birth_date,
|
||||
phone: formData.phone,
|
||||
email_private: formData.email_private,
|
||||
telegram: formData.telegram,
|
||||
child_name: formData.child_name,
|
||||
child_phone: formData.child_phone,
|
||||
child_email: formData.child_email,
|
||||
goals: formData.goals,
|
||||
|
||||
last_updated: new Date().toISOString(),
|
||||
};
|
||||
console.log('[DEBUG] Сохранение Schoolchildren Profile (payload):', { docname, payload });
|
||||
|
||||
// Сохранение или создание документа
|
||||
if (docname) {
|
||||
await createResource({
|
||||
url: 'frappe.client.save',
|
||||
params: { doc: { ...schoolProfile.data, ...payload } },
|
||||
}).submit();
|
||||
} else {
|
||||
await createResource({
|
||||
url: 'frappe.client.insert',
|
||||
params: { doc: payload },
|
||||
}).submit();
|
||||
}
|
||||
|
||||
editMode.value = false;
|
||||
// После успешного сохранения в конце функции saveProfile
|
||||
schoolProfileNotFound.value = false;
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint('Профиль сохранён');
|
||||
console.log('[DEBUG] Профиль успешно сохранён');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка при сохранении профиля:', e);
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: (e && e.message) || 'Ошибка при сохранении',
|
||||
indicator: 'red',
|
||||
});
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
await schoolProfile.reload();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('[DEBUG] Компонент смонтирован:', {
|
||||
propsUsername: props.username,
|
||||
sessionUsername: $user.data?.username,
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
});
|
||||
if ($user.data) {
|
||||
console.log('[DEBUG] Запуск profile.reload()');
|
||||
profile.reload();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.username,
|
||||
(newUsername, oldUsername) => {
|
||||
console.log('[DEBUG] Изменение props.username:', { old: oldUsername, new: newUsername });
|
||||
profile.reload();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => profile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение profile.data:', { old: oldData, new: newData });
|
||||
if (newData) {
|
||||
console.log('[DEBUG] Запуск schoolProfile.reload()');
|
||||
schoolProfile.reload();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => schoolProfile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение schoolProfile.data:', { old: oldData, new: newData });
|
||||
if (newData && !editMode.value) {
|
||||
console.log('[DEBUG] Заполнение формы из schoolProfile');
|
||||
fillFormFromProfile();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => effectiveUsername.value,
|
||||
(newUsername) => {
|
||||
console.log('[DEBUG] Изменение effectiveUsername для schoolProfile:', newUsername);
|
||||
schoolProfile.update({
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user: newUsername },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
@@ -124,19 +124,13 @@ const props = defineProps({
|
||||
|
||||
onMounted(() => {
|
||||
if ($user.data) profile.reload()
|
||||
|
||||
setActiveTab()
|
||||
})
|
||||
|
||||
const profile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
makeParams(values) {
|
||||
return {
|
||||
doctype: 'User',
|
||||
filters: {
|
||||
username: props.username,
|
||||
},
|
||||
}
|
||||
url: 'lms.lms.api.get_profile_details',
|
||||
params: {
|
||||
username: props.username,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -194,24 +188,25 @@ const isSessionUser = () => {
|
||||
return $user.data?.email === profile.data?.email
|
||||
}
|
||||
|
||||
const hasHigherAccess = () => {
|
||||
return $user.data?.is_evaluator || $user.data?.is_moderator
|
||||
}
|
||||
|
||||
const getTabButtons = () => {
|
||||
let buttons = [{ label: 'About' }, { label: 'Certificates' }]
|
||||
if ($user.data?.is_moderator) buttons.push({ label: 'Roles' })
|
||||
if (
|
||||
isSessionUser() &&
|
||||
($user.data?.is_evaluator || $user.data?.is_moderator)
|
||||
) {
|
||||
|
||||
if (hasHigherAccess()) {
|
||||
buttons.push({ label: 'Slots' })
|
||||
buttons.push({ label: 'Schedule' })
|
||||
}
|
||||
|
||||
return buttons
|
||||
}
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
let crumbs = [
|
||||
{
|
||||
label: 'People',
|
||||
label: __('People'),
|
||||
},
|
||||
{
|
||||
label: profile.data?.full_name,
|
||||
|
||||
@@ -29,6 +29,62 @@
|
||||
{{ __('No introduction') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Points Section -->
|
||||
<div class="mt-7 mb-10" v-if="energyPoints.data?.length">
|
||||
<h2 class="mb-3 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Points') }}
|
||||
</h2>
|
||||
<h2 class="mb-3 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('The last 10 score records have been uploaded') }}
|
||||
</h2>
|
||||
<ul class="space-y-4">
|
||||
<li v-for="item in energyPoints.data.slice(0, 10)" :key="item.name" class="text-sm text-gray-700">
|
||||
<div class="flex justify-between">
|
||||
<span>{{ __('Points') }}: {{ item.points }}</span>
|
||||
<span>{{ dayjs(item.creation).format('DD-MM-YYYY') }}</span>
|
||||
</div>
|
||||
<div v-if="item.rule" class="text-ink-gray-7">
|
||||
{{ __('Reason') }}: {{ item.rule }}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mt-4 text-sm">
|
||||
<div class="font-semibold">
|
||||
{{ __('Total Points') }}: {{ totalPoints }}
|
||||
</div>
|
||||
<div class="font-semibold">
|
||||
{{ __('Additional Points for MPGU Admission') }}: {{ additionalPoints }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="mt-7 text-ink-gray-7 text-sm italic">
|
||||
{{ __('No points yet') }}
|
||||
</div>
|
||||
|
||||
<!-- Courses Section -->
|
||||
<div class="mt-7 mb-10" v-if="coursesWithTitles.length">
|
||||
<h2 class="mb-3 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Completed Courses') }}
|
||||
</h2>
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div v-for="course in coursesWithTitles" :key="course.name">
|
||||
<a
|
||||
:href="`/lms/courses/${course.course}`"
|
||||
class="text-base text-ink-gray-9 hover:text-blue-600"
|
||||
>
|
||||
{{ course.title || course.course }} <!-- Отображаем title, если есть, иначе course -->
|
||||
</a>
|
||||
<div class="text-sm text-ink-gray-7">
|
||||
{{ __('Completed on') }}: {{ dayjs(course.creation).format('DD MMM YYYY') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="mt-7 text-ink-gray-7 text-sm italic">
|
||||
{{ __('No completed courses yet') }}
|
||||
</div>
|
||||
|
||||
<div class="mt-7 mb-10" v-if="badges.data?.length">
|
||||
<h2 class="mb-3 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Achievements') }}
|
||||
@@ -114,7 +170,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { inject } from 'vue'
|
||||
import { inject, computed, ref, watch } from 'vue'
|
||||
import { createResource, Popover, Button } from 'frappe-ui'
|
||||
import { X, LinkedinIcon, Twitter } from 'lucide-vue-next'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
@@ -153,6 +209,96 @@ const badges = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const courses = createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'LMS Course Progress',
|
||||
fields: ['name', 'member', 'course', 'status', 'creation'],
|
||||
filters: {
|
||||
member: props.profile.data.email,
|
||||
status: 'Complete',
|
||||
},
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
console.log('LMS Course Progress data:', data) // Отладка
|
||||
},
|
||||
})
|
||||
|
||||
const courseTitles = ref({})
|
||||
const coursesWithTitles = computed(() => {
|
||||
if (!courses.data) return []
|
||||
const result = courses.data.map(course => ({
|
||||
...course,
|
||||
title: courseTitles.value[course.course] || null,
|
||||
}))
|
||||
console.log('Courses with titles:', result) // Отладка
|
||||
return result
|
||||
})
|
||||
|
||||
// Запрашиваем title для каждого курса
|
||||
watch(
|
||||
() => courses.data,
|
||||
(newCourses) => {
|
||||
if (newCourses && newCourses.length) {
|
||||
const courseIds = newCourses.map(course => course.course)
|
||||
console.log('Course IDs:', courseIds) // Отладка
|
||||
createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'LMS Course',
|
||||
fields: ['name', 'title'],
|
||||
filters: {
|
||||
name: ['in', courseIds],
|
||||
},
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
console.log('Raw course titles data:', data) // Отладка сырых данных
|
||||
const titles = {}
|
||||
data.forEach(course => {
|
||||
titles[course.name] = course.title
|
||||
})
|
||||
courseTitles.value = titles
|
||||
console.log('Processed course titles:', titles) // Отладка обработанных titles
|
||||
},
|
||||
onError(error) {
|
||||
console.error('Error fetching course titles:', error) // Отладка ошибок
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const energyPoints = createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'Energy Point Log',
|
||||
fields: ['name', 'user', 'points', 'rule', 'creation'],
|
||||
filters: {
|
||||
user: props.profile.data.email,
|
||||
},
|
||||
limit_page_length: 1000,
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
console.log('Energy Points data:', data) // Отладка
|
||||
data.forEach(item => {
|
||||
console.log('Points for', item.name, ':', item.points, typeof item.points)
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const totalPoints = computed(() => {
|
||||
return energyPoints.data?.reduce((sum, item) => sum + (item.points || 0), 0) || 0
|
||||
})
|
||||
|
||||
const additionalPoints = computed(() => {
|
||||
const points = Math.floor(totalPoints.value / 100)
|
||||
return points < 10 ? points : 10
|
||||
})
|
||||
|
||||
const shareOnSocial = (badge, medium) => {
|
||||
let shareUrl
|
||||
const url = encodeURIComponent(
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
<h2 class="mb-3 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Certificates') }}
|
||||
</h2>
|
||||
<div class="grid grod-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div
|
||||
v-if="certificates.data?.length"
|
||||
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"
|
||||
>
|
||||
<div
|
||||
v-for="certificate in certificates.data"
|
||||
:key="certificate.name"
|
||||
@@ -19,6 +22,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-sm italic text-ink-gray-5">
|
||||
{{ __('You have not received any certificates yet.') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<Calendar
|
||||
v-if="evaluations.data?.length"
|
||||
:config="{
|
||||
defaultMode: 'Month',
|
||||
defaultMode: 'Week',
|
||||
disableModes: ['Day', 'Week'],
|
||||
redundantCellHeight: 100,
|
||||
enableShortcuts: false,
|
||||
@@ -36,7 +36,7 @@
|
||||
</Calendar>
|
||||
</div>
|
||||
</div>
|
||||
<Event v-model="showEvent" :event="currentEvent" />
|
||||
<Event v-if="showEvent" v-model="showEvent" :event="currentEvent" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { Calendar, createListResource, Button } from 'frappe-ui'
|
||||
@@ -57,7 +57,7 @@ const props = defineProps({
|
||||
const evaluations = createListResource({
|
||||
doctype: 'LMS Certificate Request',
|
||||
filters: {
|
||||
evaluator: user.data?.name,
|
||||
evaluator: props.profile.data?.name,
|
||||
status: ['!=', 'Cancelled'],
|
||||
},
|
||||
fields: [
|
||||
@@ -87,8 +87,10 @@ const evaluations = createListResource({
|
||||
mappedData.participant = d.member_name
|
||||
mappedData.id = d.name
|
||||
mappedData.venue = d.google_meet_link
|
||||
mappedData.fromDate = `${d.date} ${d.start_time}`
|
||||
mappedData.toDate = `${d.date} ${d.end_time}`
|
||||
mappedData.fromDate = `${d.date}`
|
||||
mappedData.toDate = `${d.date}`
|
||||
mappedData.fromTime = d.start_time
|
||||
mappedData.toTime = d.end_time
|
||||
mappedData.color = 'green'
|
||||
|
||||
return mappedData
|
||||
|
||||
@@ -43,18 +43,22 @@
|
||||
:options="days"
|
||||
v-model="slot.day"
|
||||
@focusout.stop="update(slot.name, 'day', slot.day)"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
<FormControl
|
||||
type="time"
|
||||
v-model="slot.start_time"
|
||||
@focusout.stop="update(slot.name, 'start_time', slot.start_time)"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
<FormControl
|
||||
type="time"
|
||||
v-model="slot.end_time"
|
||||
@focusout.stop="update(slot.name, 'end_time', slot.end_time)"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
<X
|
||||
v-if="isSessionUser()"
|
||||
@click="deleteRow(slot.name)"
|
||||
class="w-6 h-auto stroke-1.5 text-red-900 rounded-md cursor-pointer p-1 bg-surface-red-2 hidden group-hover:block"
|
||||
/>
|
||||
@@ -69,20 +73,23 @@
|
||||
:options="days"
|
||||
v-model="newSlot.day"
|
||||
@focusout.stop="add()"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
<FormControl
|
||||
type="time"
|
||||
v-model="newSlot.start_time"
|
||||
@focusout.stop="add()"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
<FormControl
|
||||
type="time"
|
||||
v-model="newSlot.end_time"
|
||||
@focusout.stop="add()"
|
||||
:disabled="!isSessionUser()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button @click="showSlotsTemplate = 1">
|
||||
<Button v-if="isSessionUser()" @click="showSlotsTemplate = 1">
|
||||
<template #prefix>
|
||||
<Plus class="w-4 h-4 stroke-1.5 text-ink-gray-7" />
|
||||
</template>
|
||||
@@ -98,6 +105,7 @@
|
||||
type="date"
|
||||
:label="__('From')"
|
||||
v-model="from"
|
||||
:disabled="!isSessionUser()"
|
||||
@blur="
|
||||
() => {
|
||||
updateUnavailability.submit({
|
||||
@@ -111,6 +119,7 @@
|
||||
type="date"
|
||||
:label="__('To')"
|
||||
v-model="to"
|
||||
:disabled="!isSessionUser()"
|
||||
@blur="
|
||||
() => {
|
||||
updateUnavailability.submit({
|
||||
@@ -122,7 +131,7 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div v-if="isSessionUser()">
|
||||
<h2 class="mb-4 text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('My calendar') }}
|
||||
</h2>
|
||||
@@ -157,11 +166,19 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (user.data?.name !== props.profile.data?.name) {
|
||||
if (user.data?.name !== props.profile.data?.name && !hasHigherAccess()) {
|
||||
window.location.href = `/user/${props.profile.data?.username}`
|
||||
}
|
||||
})
|
||||
|
||||
const hasHigherAccess = () => {
|
||||
return user.data?.is_evaluator || user.data?.is_moderator
|
||||
}
|
||||
|
||||
const isSessionUser = () => {
|
||||
return user.data?.email === props.profile.data?.email
|
||||
}
|
||||
|
||||
const showSlotsTemplate = ref(0)
|
||||
const from = ref(null)
|
||||
const to = ref(null)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="grid grid-cols-2 h-[calc(100vh_-_3rem)]">
|
||||
<div class="border-r py-5 px-8 h-full">
|
||||
<div class="font-semibold mb-2">
|
||||
<div class="font-semibold mb-2 text-ink-gray-9">
|
||||
{{ __('Problem Statement') }}
|
||||
</div>
|
||||
<div
|
||||
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex items-center justify-between p-2 bg-surface-gray-2">
|
||||
<div class="font-semibold">
|
||||
<div class="font-semibold text-ink-gray-9">
|
||||
{{ exercise.doc?.language }}
|
||||
</div>
|
||||
<div class="space-x-2">
|
||||
@@ -89,7 +89,9 @@
|
||||
class="py-3"
|
||||
>
|
||||
<div class="flex items-center mb-3">
|
||||
<span class=""> {{ __('Test {0}').format(index + 1) }} - </span>
|
||||
<span class="text-ink-gray-9">
|
||||
{{ __('Test {0}').format(index + 1) }} -
|
||||
</span>
|
||||
<span
|
||||
class="font-semibold ml-2 mr-1"
|
||||
:class="
|
||||
@@ -112,13 +114,13 @@
|
||||
<div class="text-xs text-ink-gray-7">
|
||||
{{ __('Input') }}
|
||||
</div>
|
||||
<div>{{ testCase.input }}</div>
|
||||
<div class="text-ink-gray-9">{{ testCase.input }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="text-xs text-ink-gray-7">
|
||||
{{ __('Your Output') }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-ink-gray-9">
|
||||
{{ testCase.output }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -126,7 +128,9 @@
|
||||
<div class="text-xs text-ink-gray-7">
|
||||
{{ __('Expected Output') }}
|
||||
</div>
|
||||
<div>{{ testCase.expected_output }}</div>
|
||||
<div class="text-ink-gray-9">
|
||||
{{ testCase.expected_output }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -153,6 +157,7 @@ import { Play, X, Check, Settings } from 'lucide-vue-next'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { openSettings } from '@/utils'
|
||||
import { useSettings } from '@/stores/settings'
|
||||
|
||||
const user = inject<any>('$user')
|
||||
const code = ref<string | null>('')
|
||||
@@ -162,7 +167,8 @@ const errorMessage = ref<string | null>(null)
|
||||
const testCaseSection = ref<HTMLElement | null>(null)
|
||||
const testCases = ref<TestCase[]>([])
|
||||
const boilerplate = ref<string>('')
|
||||
const { brand, livecodeURL } = sessionStore()
|
||||
const { brand } = sessionStore()
|
||||
const { livecodeURL } = useSettings()
|
||||
const router = useRouter()
|
||||
const fromLesson = ref(false)
|
||||
const falconURL = ref<string>('https://falcon.frappe.io/')
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<div class="pb-5">
|
||||
<div class="flex items-center justify-between mt-5 mb-4">
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Courses') }}
|
||||
</div>
|
||||
<Button @click="openForm('course')">
|
||||
@@ -106,12 +106,13 @@
|
||||
|
||||
<div>
|
||||
<div class="flex items-center justify-between mt-5 mb-4">
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ __('Members') }}
|
||||
</div>
|
||||
|
||||
<div class="space-x-2">
|
||||
<Button
|
||||
v-if="programMembers.data.length > 0"
|
||||
@click="
|
||||
() => {
|
||||
showProgressDialog = true
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
@click="openForm(program.name)"
|
||||
class="border rounded-md p-3 hover:border-outline-gray-3 cursor-pointer space-y-2"
|
||||
>
|
||||
<div class="text-lg font-semibold">
|
||||
<div class="text-lg font-semibold text-ink-gray-9">
|
||||
{{ program.name }}
|
||||
</div>
|
||||
<div class="flex items-center space-x-1">
|
||||
<div class="flex items-center space-x-1 text-ink-gray-7">
|
||||
<BookOpen class="h-4 w-4 stroke-1.5 mr-1" />
|
||||
<span>
|
||||
{{ program.course_count }}
|
||||
{{ program.course_count == 1 ? __('Course') : __('Courses') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-1">
|
||||
<div class="flex items-center space-x-1 text-ink-gray-7">
|
||||
<User class="h-4 w-4 stroke-1.5 mr-1" />
|
||||
<span>
|
||||
{{ program.member_count || 0 }}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
class="sticky top-0 z-10 flex items-center justify-between border-b bg-surface-white px-3 py-2.5 sm:px-5"
|
||||
>
|
||||
<Breadcrumbs :items="breadcrumbs" />
|
||||
<div v-if="!readOnlyMode" class="space-x-2">
|
||||
<div v-if="!readOnlyMode" class="flex items-center space-x-2">
|
||||
<Badge v-if="quizDetails.isDirty" theme="orange">
|
||||
{{ __('Not Saved') }}
|
||||
</Badge>
|
||||
@@ -254,11 +254,7 @@ const props = defineProps({
|
||||
const questions = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
if (
|
||||
props.quizID == 'new' &&
|
||||
!user.data?.is_moderator &&
|
||||
!user.data?.is_instructor
|
||||
) {
|
||||
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
||||
router.push({ name: 'Courses' })
|
||||
}
|
||||
if (props.quizID !== 'new') {
|
||||
|
||||
@@ -11,6 +11,32 @@
|
||||
>
|
||||
<Quiz :quizName="quizID" />
|
||||
</div>
|
||||
<div>
|
||||
<!--<button @click="toggleChatGPT" class="btn btn-primary">Решить с ChatGPT</button>-->
|
||||
</div>
|
||||
<div v-if="showChat" class="chat-container mt-4">
|
||||
<h2>AI-тьютор</h2>
|
||||
<div class="chat-window">
|
||||
<div id="chat-box" class="chat-box">
|
||||
<div v-for="(message, index) in chatHistory" :key="index" class="message">
|
||||
<span :class="{ 'user-message': message.isUser, 'ai-message': !message.isUser }">
|
||||
{{ message.text }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="chatHistory.length === 0" class="placeholder-text">Загрузка ответа...</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-input mt-4">
|
||||
<input
|
||||
v-model="userInput"
|
||||
type="text"
|
||||
placeholder="Введите ваше сообщение..."
|
||||
class="w-full p-2 border rounded-md"
|
||||
@keyup.enter="sendMessage"
|
||||
/>
|
||||
<button @click="sendMessage" class="btn btn-primary ml-2">Отправить</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import Quiz from '@/components/Quiz.vue'
|
||||
@@ -24,6 +50,12 @@ const user = inject('$user')
|
||||
const router = useRouter()
|
||||
const fromLesson = ref(false)
|
||||
|
||||
const showChat = ref(false)
|
||||
const chatResponse = ref(null) // Временная переменная для текущего ответа
|
||||
const currentQuestionIndex = ref(0) // Индекс текущего вопроса
|
||||
const userInput = ref('') // Поле для ввода сообщения
|
||||
const chatHistory = ref([]) // История сообщений
|
||||
|
||||
onMounted(() => {
|
||||
if (!user.data) {
|
||||
router.push({ name: 'Courses' })
|
||||
@@ -41,6 +73,21 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const quizData = createResource({
|
||||
url: 'frappe.client.get',
|
||||
params: {
|
||||
doctype: 'LMS Quiz',
|
||||
name: props.quizID,
|
||||
},
|
||||
auto: true,
|
||||
onSuccess: (data) => {
|
||||
console.log('[DEBUG] quizData onSuccess:', data)
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error('[DEBUG] quizData onError:', err)
|
||||
},
|
||||
})
|
||||
|
||||
const title = createResource({
|
||||
url: 'frappe.client.get_value',
|
||||
params: {
|
||||
@@ -63,4 +110,283 @@ usePageMeta(() => {
|
||||
icon: brand.favicon,
|
||||
}
|
||||
})
|
||||
|
||||
const handleCurrentQuestion = (index) => {
|
||||
currentQuestionIndex.value = index
|
||||
console.log('[DEBUG] Текущий индекс вопроса из Quiz.vue:', index)
|
||||
}
|
||||
|
||||
const sendMessage = async () => {
|
||||
if (!userInput.value.trim()) return;
|
||||
|
||||
// Добавляем сообщение пользователя в историю
|
||||
chatHistory.value.push({ text: userInput.value, isUser: true });
|
||||
console.log('[DEBUG] Пользовательское сообщение:', userInput.value);
|
||||
|
||||
// Сбрасываем поле ввода
|
||||
const userMessage = userInput.value;
|
||||
userInput.value = '';
|
||||
|
||||
try {
|
||||
console.log('[DEBUG] Отправка запроса к прокси с пользовательским сообщением...');
|
||||
const res = await fetch('https://openai.enlightrussia.ru/chat', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-KEY': 'a38ed6248c82e31f014b7459479d4c75154e41a331f8a4d9b4afc4b10cbc884a'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
prompt: generatePrompt(userMessage),
|
||||
model: 'gpt-4o',
|
||||
system_prompt: `Ты — опытный, доброжелательный и очень терпеливый учитель. Твоя задача — сопровождать ученика в самостоятельном разборе задачи, не раскрывая ему готовое решение и не выдавая правильного ответа напрямую.
|
||||
Ни при каких условиях нельзя выдавать готовый ответ. Ученик должен сам дойти до него. Обязательно нужно разбирать процесс решений по шагам, задавая ученику по одному вопросу за один шаг и ожидая от него ответа.
|
||||
Говори и отвечай на русском языке, простыми и понятными формулировками. Будь вежлив, отзывчив и дружелюбен. Показывай искреннее желание помочь. Подбадривай ученика, если он ошибается или затрудняется.`
|
||||
})
|
||||
});
|
||||
|
||||
console.log('[DEBUG] Ответ от прокси:', res.status, res.statusText);
|
||||
if (!res.ok) {
|
||||
const errorText = await res.text();
|
||||
console.log('[DEBUG] Ошибка ответа от прокси:', errorText);
|
||||
throw new Error(`Ошибка API: ${res.status} ${errorText}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
console.log('[DEBUG] Получен ответ от GPT:', data);
|
||||
chatHistory.value.push({ text: data.answer, isUser: false });
|
||||
} catch (err) {
|
||||
console.error('[DEBUG] Ошибка в sendMessage:', err);
|
||||
chatHistory.value.push({ text: `Ошибка: ${err.message}`, isUser: false });
|
||||
}
|
||||
};
|
||||
|
||||
const toggleChatGPT = async () => {
|
||||
console.log('[DEBUG] toggleChatGPT вызван, showChat:', showChat.value);
|
||||
showChat.value = !showChat.value;
|
||||
if (!showChat.value) {
|
||||
chatResponse.value = null;
|
||||
chatHistory.value = [];
|
||||
console.log('[DEBUG] Чат закрыт, chatResponse и история сброшены');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('[DEBUG] Начало обработки, quizData:', quizData);
|
||||
if (quizData.loading) {
|
||||
chatHistory.value.push({ text: 'Загрузка данных квиза...', isUser: false });
|
||||
console.log('[DEBUG] Данные квиза загружаются');
|
||||
return;
|
||||
}
|
||||
|
||||
if (quizData.error) {
|
||||
throw new Error(`Ошибка загрузки квиза: ${quizData.error.message}`);
|
||||
}
|
||||
|
||||
const quiz = quizData.data;
|
||||
if (!quiz) {
|
||||
chatHistory.value.push({ text: 'Данные квиза не загружены', isUser: false });
|
||||
console.log('[DEBUG] quizData.data отсутствует');
|
||||
return;
|
||||
}
|
||||
const quiz_title = quiz.title || 'Без названия';
|
||||
console.log('[DEBUG] Получен quiz:', quiz, quiz_title);
|
||||
if (!quiz.questions || quiz.questions.length === 0) {
|
||||
chatHistory.value.push({ text: 'Вопросы не найдены', isUser: false });
|
||||
console.log('[DEBUG] Вопросы не найдены в quiz:', quiz);
|
||||
return;
|
||||
}
|
||||
|
||||
// Используем текущий индекс
|
||||
const currentQuestion = quiz.questions[currentQuestionIndex.value];
|
||||
if (!currentQuestion?.question_detail) {
|
||||
chatHistory.value.push({ text: 'Детали вопроса не найдены', isUser: false });
|
||||
console.log('[DEBUG] Текущий вопрос отсутствует:', currentQuestion);
|
||||
return;
|
||||
}
|
||||
|
||||
// Создаём и ждём загрузки данных вопроса
|
||||
const questionData = await new Promise((resolve) => {
|
||||
const resource = createResource({
|
||||
url: 'frappe.client.get',
|
||||
params: {
|
||||
doctype: 'LMS Question',
|
||||
name: currentQuestion.question,
|
||||
},
|
||||
auto: true,
|
||||
onSuccess: (data) => {
|
||||
console.log('[DEBUG] questionData onSuccess:', data);
|
||||
resolve(data);
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error('[DEBUG] questionData onError:', err);
|
||||
resolve(null);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if (!questionData) {
|
||||
chatHistory.value.push({ text: 'Данные вопроса не загружены', isUser: false });
|
||||
console.log('[DEBUG] Данные вопроса отсутствуют');
|
||||
return;
|
||||
}
|
||||
|
||||
let questionDataPrompt, question, prompt, correct_answer, options = [], possibilitys = [];
|
||||
|
||||
if (questionData.type === "Choices") {
|
||||
question = currentQuestion.question_detail;
|
||||
options = [
|
||||
questionData.option_1 || '',
|
||||
questionData.option_2 || '',
|
||||
questionData.option_3 || '',
|
||||
questionData.option_4 || '',
|
||||
].filter(Boolean);
|
||||
correct_answer = null;
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
if (questionData[`is_correct_${i}`] === 1) {
|
||||
correct_answer = questionData[`option_${i}`];
|
||||
console.log(`Правильный ответ ${i}:`, correct_answer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log('[DEBUG] Получен вопрос, варианты и ответ:', { question, options, correct_answer });
|
||||
questionDataPrompt = `Это вопрос типа: ${questionData.type} из квиза под названием ${quiz_title}.\n${question}\nВарианты ответа: ${options.join(', ')}\nПравильный ответ: ${correct_answer}`;
|
||||
console.log('[DEBUG] Данные для промта:', questionDataPrompt)
|
||||
prompt = generatePrompt(questionDataPrompt);
|
||||
} else if (questionData.type === "User Input") {
|
||||
question = currentQuestion.question_detail;
|
||||
possibilitys = [
|
||||
questionData.possibility_1 || '',
|
||||
questionData.possibility_2 || '',
|
||||
questionData.possibility_3 || '',
|
||||
questionData.possibility_4 || '',
|
||||
].filter(Boolean);
|
||||
console.log('[DEBUG] Получен вопрос и возможные варианты:', { question, possibilitys });
|
||||
questionDataPrompt = `Это вопрос типа: ${questionData.type} из квиза под названием ${quiz_title}.\n${question}\nВозможные варианты ответа: ${possibilitys.join(', ')}`;
|
||||
console.log('[DEBUG] Данные для промта:', questionDataPrompt)
|
||||
prompt = generatePrompt(questionDataPrompt);
|
||||
} else {
|
||||
question = currentQuestion.question_detail;
|
||||
console.log('[DEBUG] Получен вопрос:', { question });
|
||||
questionDataPrompt = `Это вопрос типа: ${questionData.type} из квиза под названием ${quiz_title}.\n${question}`;
|
||||
console.log('[DEBUG] Данные для промта:', questionDataPrompt)
|
||||
prompt = generatePrompt(questionDataPrompt);
|
||||
}
|
||||
|
||||
if (!question) {
|
||||
chatHistory.value.push({ text: 'Текст вопроса не найден', isUser: false });
|
||||
console.log('[DEBUG] Текст вопроса отсутствует в currentQuestion:', currentQuestion);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[DEBUG] Сформирован промпт:', prompt);
|
||||
console.log('[DEBUG] Отправка запроса к прокси...');
|
||||
const res = await fetch('https://openai.enlightrussia.ru/chat', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-KEY': 'a38ed6248c82e31f014b7459479d4c75154e41a331f8a4d9b4afc4b10cbc884a'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
prompt: prompt,
|
||||
model: 'gpt-4o',
|
||||
system_prompt: `1. Роль
|
||||
Ты — опытный, доброжелательный и очень терпеливый учитель. Твоя задача — сопровождать ученика в самостоятельном разборе задачи, не раскрывая ему готовое решение и не выдавая правильного ответа напрямую.
|
||||
Ни при каких условиях нельзя выдавать готовый ответ. Ученик должен сам дойти до него. Обязательно нужно разбирать процесс решений по шагам, задавая ученику по одному вопросу за один шаг и ожидая от него ответа.
|
||||
2. Стиль общения
|
||||
Говори и отвечай на русском языке, простыми и понятными формулировками.
|
||||
Будь вежлив, отзывчив и дружелюбен.
|
||||
Показывай искреннее желание помочь.
|
||||
Подбадривай ученика, если он ошибается или затрудняется.
|
||||
3. Пошаговый подход
|
||||
Начинай с запроса к ученику: попроси его показать или описать задание. Если возможно, пусть он загрузит скриншот, документ или текст задания.
|
||||
Не говори финальный ответ сразу. Вместо этого:
|
||||
1. Спроси, что ученик уже знает или какие идеи у него есть.
|
||||
2. Дай наводящие вопросы, чтобы понять, в каком месте он испытывает затруднение.
|
||||
3. Подсказывай принципы или формулы, которые могут помочь, но не окончательный результат.
|
||||
4. Делай это пошагово, пока ученик не найдёт решение самостоятельно (или не выскажет версию, близкую к правильной).
|
||||
При необходимости:
|
||||
Повтори ключевые определения и формулы.
|
||||
Предложи разобрать аналогичный, но более простой пример. Обязательно нужно разбирать процесс решений по шагам, задавая ученику по одному вопросу за один шаг и ожидая от него ответа. Ни в коем случае не давай сразу решение.`
|
||||
})
|
||||
});
|
||||
|
||||
console.log('[DEBUG] Ответ от прокси:', res.status, res.statusText);
|
||||
if (!res.ok) {
|
||||
const errorText = await res.text();
|
||||
console.log('[DEBUG] Ошибка ответа от прокси:', errorText);
|
||||
throw new Error(`Ошибка API: ${res.status} ${errorText}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
console.log('[DEBUG] Получен ответ от GPT:', data);
|
||||
chatHistory.value.push({ text: data.answer, isUser: false });
|
||||
chatResponse.value = null; // Сбрасываем chatResponse после добавления в историю
|
||||
} catch (err) {
|
||||
console.error('[DEBUG] Ошибка в toggleChatGPT:', err);
|
||||
chatHistory.value.push({ text: `Ошибка: ${err.message}`, isUser: false });
|
||||
chatResponse.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Функция для генерации промпта с историей
|
||||
const generatePrompt = (userMsg) => {
|
||||
let prompt = `Текущая задача: "${userMsg}".\n`;
|
||||
prompt += 'История диалога:\n';
|
||||
chatHistory.value.forEach(msg => {
|
||||
prompt += `${msg.isUser ? 'Ученик' : 'Учитель'}: ${msg.text}\n`;
|
||||
});
|
||||
prompt += `\nНовое сообщение от ученика: ${userMsg}`;
|
||||
return prompt;
|
||||
};
|
||||
|
||||
//updateDocumentTitle(pageMeta)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chat-container {
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
.chat-window {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.chat-box {
|
||||
min-height: 100px;
|
||||
}
|
||||
.placeholder-text {
|
||||
color: #94a3b8;
|
||||
text-align: center;
|
||||
}
|
||||
.message {
|
||||
margin: 5px 0;
|
||||
}
|
||||
.user-message {
|
||||
background-color: #e3f2fd;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
.ai-message {
|
||||
background-color: #f0f0f0;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
.chat-input input {
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -56,8 +56,8 @@
|
||||
<span class="font-semibold"> {{ __('Question') }}: </span>
|
||||
<span class="leading-5" v-html="row.question"> </span>
|
||||
</div>
|
||||
<div class="">
|
||||
<span class="font-semibold"> {{ __('Answer') }} </span>
|
||||
<div class="text-ink-gray-9">
|
||||
<span class="font-semibold"> {{ __('Answer') }}: </span>
|
||||
<span class="leading-5" v-html="row.answer"></span>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-5">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Breadcrumbs :items="breadcrumbs" />
|
||||
</header>
|
||||
<div v-if="submissions.data?.length" class="md:w-3/4 md:mx-auto py-5 mx-5">
|
||||
<div class="text-xl font-semibold mb-5">
|
||||
<div class="text-xl font-semibold mb-5 text-ink-gray-9">
|
||||
{{ submissions.data[0].quiz_title }}
|
||||
</div>
|
||||
<ListView
|
||||
@@ -40,7 +40,7 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<EmptyState v-else />
|
||||
<EmptyState v-else type="Quiz Submissions" />
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
|
||||
923
frontend/src/pages/SchoolchildrenProfile.vue
Normal file
923
frontend/src/pages/SchoolchildrenProfile.vue
Normal file
@@ -0,0 +1,923 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-white">
|
||||
<NoPermission v-if="!$user.data" />
|
||||
|
||||
<div v-else-if="profile.error" class="p-6">
|
||||
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-sm p-6 border border-red-200">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки профиля: {{ profile.error.message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="profile.data">
|
||||
<header class="sticky top-0 z-10 flex items-center justify-between bg-white px-6 py-4">
|
||||
<Breadcrumbs class="h-7" :items="breadcrumbs" />
|
||||
</header>
|
||||
|
||||
<div class="mx-auto max-w-6xl px-4 py-6">
|
||||
<!-- Profile Header -->
|
||||
<div v-if="!schoolProfileNotFound" class="bg-gradient-to-r from-teal-100 to-teal-600 rounded-2xl shadow-sm border border-gray-200 p-6 -mt-4 relative">
|
||||
<div class="flex flex-col md:flex-row md:items-center gap-6">
|
||||
<div class="flex-1">
|
||||
<h2 class="text-3xl font-bold text-gray-900">{{ displayName }}</h2>
|
||||
<div
|
||||
v-if="profile.data.bio"
|
||||
v-html="
|
||||
DOMPurify.sanitize(decodeEntities(profile.data.bio), {
|
||||
ALLOWED_TAGS: [
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'a',
|
||||
'p',
|
||||
'br',
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
'img',
|
||||
],
|
||||
ALLOWED_ATTR: ['href', 'target', 'rel', 'src'],
|
||||
})
|
||||
"
|
||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-outline-gray-2 prose-th:border-outline-gray-2 prose-td:relative prose-th:relative prose-th:bg-surface-gray-2 prose-sm max-w-none !whitespace-normal mt-2 text-gray-700"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div v-if="$user.data && isSessionUser() && !schoolProfileNotFound" class="md:ml-auto">
|
||||
<Button @click="toggleEdit()" class="bg-white hover:bg-gray-100 px-5 py-2.5 rounded-lg transition-colors duration-200">
|
||||
<template #prefix>
|
||||
<Edit class="w-4 h-4 stroke-1.5" />
|
||||
</template>
|
||||
{{ editMode ? 'Отменить редактирование' : 'Редактировать профиль' }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VIEW MODE -->
|
||||
<div v-if="!editMode" class="mt-6">
|
||||
<!-- Пустой профиль -->
|
||||
<div v-if="schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="p-8 text-center">
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="mx-auto w-20 h-20 bg-teal-100 rounded-full flex items-center justify-center mb-6">
|
||||
<svg class="w-10 h-10 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h3 class="text-2xl font-bold text-gray-900 mb-3">Профиль школьника еще не заполнен</h3>
|
||||
|
||||
<p class="text-gray-600 mb-6">
|
||||
Чтобы получить доступ ко всем возможностям платформы, заполните информацию о себе.
|
||||
Это поможет наставникам лучше понять ваши интересы и цели.
|
||||
</p>
|
||||
|
||||
<div class="bg-teal-50 border border-teal-100 rounded-lg p-5 mb-6 text-left">
|
||||
<h4 class="font-semibold text-teal-800 mb-3 flex items-center gap-2">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Заполнив профиль, вы получите:
|
||||
</h4>
|
||||
<ul class="space-y-2 text-sm text-gray-700">
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Персонализированные рекомендации по обучению</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Подбор наставников по вашим интересам</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Доступ к закрытым мероприятиям и курсам</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@click="toggleEdit()"
|
||||
class="bg-teal-600 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 shadow-sm hover:shadow-md"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
||||
</svg>
|
||||
</template>
|
||||
Заполнить профиль школьника
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загружающийся профиль -->
|
||||
<div v-else-if="schoolProfile.loading" class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ошибка загрузки (кроме DoesNotExistError) -->
|
||||
<div v-else-if="schoolProfile.error && !schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-red-200 p-6">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки данных школьника: {{ schoolProfile.error.message }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Загруженный профиль -->
|
||||
<div v-else-if="schoolProfile.data && !schoolProfileNotFound" class="space-y-6">
|
||||
<!-- Основная информация -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Основная информация</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Фамилия:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.last_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Имя:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.first_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Отчество:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.middle_name || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Дата рождения:</span>
|
||||
<span class="text-gray-900">{{ formattedDate(schoolProfile.data.birth_date) || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Школа:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.school || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Класс:</span>
|
||||
<span class="text-gray-900">{{ schoolProfile.data.grade || '—' }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Телефон:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.phone) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Email:</span>
|
||||
<span class="text-gray-900 font-mono">{{ maskPrivate(schoolProfile.data.email_private) }}</span>
|
||||
</div>
|
||||
<div class="flex items-start">
|
||||
<span class="inline-block w-48 text-gray-700 font-medium">Telegram:</span>
|
||||
<div class="flex-1">
|
||||
<a v-if="schoolProfile.data.telegram"
|
||||
:href="formatTelegram(schoolProfile.data.telegram)"
|
||||
target="_blank"
|
||||
class="inline-flex items-center gap-2 text-primary-600 hover:text-primary-700 font-medium transition-colors">
|
||||
<span>{{ schoolProfile.data.telegram.replace('@', '') }}</span>
|
||||
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69.01-.03.01-.14-.06-.2-.07-.06-.17-.04-.24-.02-.1.02-1.69 1.09-4.78 3.2-.45.31-.86.46-1.23.45-.41-.01-1.2-.23-1.79-.42-.72-.23-1.29-.36-1.24-.76.03-.24.37-.48 1.01-.74 3.97-1.67 6.62-2.77 7.94-3.31 3.26-1.33 3.94-1.56 4.38-1.56.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<span v-else class="text-gray-500">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ЕГЭ и Предметы для обучения -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">ЕГЭ (планируется)</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div v-if="schoolProfile.data.exams && schoolProfile.data.exams.length > 0" class="flex flex-wrap gap-2">
|
||||
<span v-for="exam in schoolProfile.data.exams" :key="exam"
|
||||
class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-teal-100">
|
||||
{{ exam }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-else class="text-gray-500 italic">Не указано</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Чему хочется научиться</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div v-if="schoolProfile.data.learn_subjects && schoolProfile.data.learn_subjects.length > 0" class="flex flex-wrap gap-2">
|
||||
<span v-for="subject in schoolProfile.data.learn_subjects" :key="subject"
|
||||
class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-teal-100">
|
||||
{{ subject }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-else class="text-gray-500 italic">Не указано</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- О себе, интересах и мечтах -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Коротко о своих интересах</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.interests || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Коротко о себе</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.about_me || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Коротко о мечтах</h3>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<p class="text-gray-700 leading-relaxed whitespace-pre-line">{{ schoolProfile.data.dreams || 'Информация не указана' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="text-center py-12">
|
||||
<div class="mx-auto w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4">
|
||||
<svg class="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-semibold text-gray-900 mb-2">Данные профиля не найдены</h3>
|
||||
<p class="text-gray-600">Информация о школьнике отсутствует</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EDIT MODE -->
|
||||
<div v-else class="mt-6">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
<h3 class="text-xl font-semibold text-white">Редактирование профиля школьника</h3>
|
||||
<p class="text-sm text-gray-200 mt-1">Заполните информацию о себе</p>
|
||||
</div>
|
||||
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Левая колонка -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Личная информация</h4>
|
||||
|
||||
<Input
|
||||
v-model="form.last_name"
|
||||
label="Фамилия"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.first_name"
|
||||
label="Имя"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.middle_name"
|
||||
label="Отчество"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Дата рождения</label>
|
||||
<DatePicker
|
||||
v-model="form.birth_date"
|
||||
class="w-full bg-gray-50 border-gray-300 rounded-lg focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-model="form.phone"
|
||||
label="Телефон (не публиковать)"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.email_private"
|
||||
label="Email (не публиковать)"
|
||||
type="email"
|
||||
placeholder="example@email.com"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Input
|
||||
v-model="form.telegram"
|
||||
label="Telegram"
|
||||
placeholder="username или t.me/username"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Правая колонка -->
|
||||
<div class="space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Образование</h4>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Школа</label>
|
||||
<input
|
||||
type="text"
|
||||
v-model="schoolQuery"
|
||||
@input="debouncedSearchSchool"
|
||||
class="w-full bg-gray-50 border border-gray-300 rounded-lg px-4 py-2.5 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-colors"
|
||||
placeholder="Начните вводить название школы"
|
||||
/>
|
||||
<div v-if="schoolResults.length" class="mt-2 border border-gray-300 rounded-lg overflow-hidden shadow-lg bg-white">
|
||||
<div
|
||||
v-for="s in schoolResults"
|
||||
:key="s.school"
|
||||
class="p-3 cursor-pointer hover:bg-primary-50 border-b border-gray-100 last:border-b-0 transition-colors"
|
||||
@click="selectSchool(s)"
|
||||
>
|
||||
<div class="font-medium text-gray-900">{{ s.school }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">{{ s.adress }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.school_name && !schoolResults.length" class="mt-2 text-sm text-gray-600">
|
||||
<span class="font-medium">Выбрана:</span> {{ form.school_name }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Класс</label>
|
||||
<Select
|
||||
v-model="form.grade"
|
||||
:options="['10', '11']"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-3 font-medium text-gray-700">ЕГЭ (отметьте):</label>
|
||||
<div class="grid grid-cols-2 gap-3 max-h-48 overflow-y-auto p-3 border border-gray-200 rounded-lg bg-gray-50">
|
||||
<label v-for="e in examOptions" :key="e" class="flex items-center space-x-3 p-2 hover:bg-white rounded-md transition-colors cursor-pointer">
|
||||
<input type="checkbox" :value="e" v-model="form.exams"
|
||||
class="h-4 w-4 text-teal-600 focus:ring-teal-500 border-gray-300 rounded" />
|
||||
<span class="text-sm text-gray-700">{{ e }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<p v-if="form.exams.length > 0" class="mt-2 text-sm text-gray-600">
|
||||
Выбрано: {{ form.exams.length }} предмет(ов)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-3 font-medium text-gray-700">Чему хочется научиться:</label>
|
||||
<div class="grid grid-cols-2 gap-3 max-h-48 overflow-y-auto p-3 border border-gray-200 rounded-lg bg-gray-50">
|
||||
<label v-for="s in learnOptions" :key="s" class="flex items-center space-x-3 p-2 hover:bg-white rounded-md transition-colors cursor-pointer">
|
||||
<input type="checkbox" :value="s" v-model="form.learn_subjects"
|
||||
class="h-4 w-4 text-teal-600 focus:ring-teal-500 border-gray-300 rounded" />
|
||||
<span class="text-sm text-gray-700">{{ s }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<p v-if="form.learn_subjects.length > 0" class="mt-2 text-sm text-gray-600">
|
||||
Выбрано: {{ form.learn_subjects.length }} направлений
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Текстовые поля -->
|
||||
<div class="mt-8 space-y-6">
|
||||
<h4 class="text-lg font-semibold text-gray-900 border-b pb-2">Дополнительная информация</h4>
|
||||
|
||||
<Textarea
|
||||
v-model="form.interests"
|
||||
label="Коротко о своих интересах (2-3 предложения)"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<Textarea
|
||||
v-model="form.about_me"
|
||||
label="Коротко о себе"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
v-model="form.dreams"
|
||||
label="Коротко о своих мечтах"
|
||||
rows="4"
|
||||
class="bg-gray-50 border-gray-300 focus:border-primary-500 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="mt-8 pt-6 border-t border-gray-200 flex gap-3">
|
||||
<Button
|
||||
@click="saveProfile"
|
||||
:loading="saving"
|
||||
class="bg-teal-400 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 flex items-center gap-2"
|
||||
>
|
||||
{{ saving ? 'Сохранение...' : 'Сохранить изменения' }}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
@click="toggleEdit()"
|
||||
class="border-gray-300 text-gray-700 hover:bg-gray-50 px-6 py-3 rounded-lg font-medium transition-colors duration-200"
|
||||
>
|
||||
Отмена
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex items-center justify-center min-h-screen">
|
||||
<div class="text-center">
|
||||
<div class="animate-spin rounded-full h-16 w-16 border-b-2 border-primary-600 mx-auto"></div>
|
||||
<p class="mt-4 text-lg text-gray-600">Загрузка профиля...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Плавные переходы для интерактивных элементов */
|
||||
.border-gray-300 {
|
||||
transition: border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.bg-primary-50 {
|
||||
background-color: rgba(59, 130, 246, 0.05);
|
||||
}
|
||||
|
||||
/* Стилизация скроллбара для выпадающих списков */
|
||||
.overflow-y-auto::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
|
||||
background: #a1a1a1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Скрипт остается без изменений -->
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject, watch, onMounted } from 'vue';
|
||||
import { Breadcrumbs, createResource, Button, Input, DatePicker, Select, Textarea } from 'frappe-ui';
|
||||
import { sessionStore } from '@/stores/session';
|
||||
import NoPermission from '@/components/NoPermission.vue';
|
||||
import { Edit } from 'lucide-vue-next';
|
||||
import { convertToTitleCase, updateDocumentTitle } from '@/utils';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { decodeEntities } from '@/utils'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
const { user } = sessionStore();
|
||||
const $user = inject('$user');
|
||||
const schoolProfileNotFound = ref(false);
|
||||
|
||||
// Логирование инициализации
|
||||
console.log('[DEBUG] Инициализация компонента:', {
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
username: $user.data?.username,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
username: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const effectiveUsername = computed(() => {
|
||||
const username = props.username || $user.data?.username || '';
|
||||
console.log('[DEBUG] Вычисление effectiveUsername:', { propsUsername: props.username, sessionUsername: $user.data?.username, result: username });
|
||||
return username;
|
||||
});
|
||||
|
||||
const editMode = ref(false);
|
||||
const saving = ref(false);
|
||||
|
||||
const examOptions = [
|
||||
'Русский язык', 'Математика(базовый)', 'Математика(профильный)', 'Физика', 'Химия', 'Информатика',
|
||||
'Биология', 'История', 'География', 'Английский язык', 'Немецкий язык', 'Французский язык', 'Испанский язык',
|
||||
'Китайский язык', 'Обществознание', 'Литература'
|
||||
];
|
||||
|
||||
const learnOptions = [
|
||||
'Программирование', 'Дизайн', 'Актерское мастерство', 'Риторика', 'Робототехника', 'Иностранные языки',
|
||||
'Математика углубленно', 'Физика углубленно'
|
||||
];
|
||||
|
||||
const profile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
makeParams(values) {
|
||||
const username = effectiveUsername.value;
|
||||
console.log('[DEBUG] Запрос profile:', { doctype: 'User', filters: { username } });
|
||||
return {
|
||||
doctype: 'User',
|
||||
filters: { username },
|
||||
};
|
||||
},
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль пользователя: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const schoolProfile = createResource({
|
||||
url: 'frappe.client.get',
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user:user },
|
||||
},
|
||||
auto: false,
|
||||
transform(data) {
|
||||
if (!data) {
|
||||
schoolProfileNotFound.value = true;
|
||||
return null;
|
||||
}
|
||||
let doc = data || {};
|
||||
console.log('[DEBUG] Данные schoolProfile до трансформации:', doc);
|
||||
try {
|
||||
doc.exams = doc.exams ? doc.exams.map(e => e.exam_subject) : [];
|
||||
doc.learn_subjects = doc.learn_subjects ? doc.learn_subjects.map(s => s.learn_subject) : [];
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка трансформации данных:', e);
|
||||
doc.exams = [];
|
||||
doc.learn_subjects = [];
|
||||
}
|
||||
console.log('[DEBUG] Данные schoolProfile после трансформации:', doc);
|
||||
return doc;
|
||||
},
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль школьника загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
// Проверяем, является ли ошибка "не найдено"
|
||||
if (error.exc_type === 'DoesNotExistError' || error.message?.includes('DoesNotExist')) {
|
||||
console.log('[DEBUG] Профиль школьника не найден, создаем новый');
|
||||
schoolProfileNotFound.value = true;
|
||||
} else {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля школьника:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль школьника: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const form = ref({
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
middle_name: '',
|
||||
birth_date: '',
|
||||
school: '',
|
||||
//school_name: '',
|
||||
grade: '',
|
||||
phone: '',
|
||||
email_private: '',
|
||||
telegram: '',
|
||||
exams: [],
|
||||
learn_subjects: [],
|
||||
interests: '',
|
||||
about_me: '',
|
||||
dreams: ''
|
||||
});
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
const username = effectiveUsername.value;
|
||||
const crumbs = [
|
||||
{
|
||||
label: 'People',
|
||||
route: { name: 'People' },
|
||||
},
|
||||
{
|
||||
label: profile.data?.full_name || 'Профиль',
|
||||
route: username ? {
|
||||
name: 'Profile',
|
||||
params: { username },
|
||||
} : undefined,
|
||||
},
|
||||
];
|
||||
console.log('[DEBUG] Хлебные крошки:', crumbs);
|
||||
return crumbs;
|
||||
});
|
||||
|
||||
const pageMeta = computed(() => {
|
||||
const meta = {
|
||||
title: profile.data?.full_name || 'Профиль',
|
||||
description: profile.data?.headline || '',
|
||||
};
|
||||
console.log('[DEBUG] Мета-данные страницы:', meta);
|
||||
return meta;
|
||||
});
|
||||
|
||||
const displayName = computed(() => {
|
||||
if (!profile.data) {
|
||||
console.log('[DEBUG] displayName: profile.data не загружен');
|
||||
return 'Загрузка...';
|
||||
}
|
||||
const name = profile.data?.full_name || `${form.value.first_name || ''} ${form.value.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Отображаемое имя:', name);
|
||||
return name;
|
||||
});
|
||||
|
||||
const isSessionUser = () => {
|
||||
const sessionUser = $user.data?.username;
|
||||
const profileUser = effectiveUsername.value;
|
||||
const isSession = sessionUser === profileUser;
|
||||
console.log('[DEBUG] Проверка isSessionUser:', { sessionUser, profileUser, isSession });
|
||||
return isSession;
|
||||
};
|
||||
|
||||
function formattedDate(d) {
|
||||
if (!d) return '';
|
||||
try {
|
||||
return new Date(d).toLocaleDateString('ru-RU');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка форматирования даты:', e, { date: d });
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
function maskPrivate(val) {
|
||||
if (!val) return '-';
|
||||
if (val.includes('@')) {
|
||||
const parts = val.split('@');
|
||||
return parts[0].slice(0, 1) + '***@' + parts[1];
|
||||
}
|
||||
return val.slice(0, 3) + '***' + val.slice(-2);
|
||||
}
|
||||
|
||||
function formatTelegram(t) {
|
||||
if (!t) return '';
|
||||
if (t.startsWith('t.me/') || t.startsWith('https://t.me/')) return (t.startsWith('http') ? t : 'https://' + t);
|
||||
return 'https://t.me/' + t.replace(/^@/, '');
|
||||
}
|
||||
|
||||
function fillFormFromProfile() {
|
||||
console.log('[DEBUG] Заполнение формы:', {
|
||||
schoolProfile: schoolProfile.data,
|
||||
profile: profile.data,
|
||||
currentForm: JSON.stringify(form.value, null, 2),
|
||||
});
|
||||
form.value.first_name = schoolProfile.data?.first_name || profile.data?.first_name || '';
|
||||
form.value.last_name = schoolProfile.data?.last_name || profile.data?.last_name || '';
|
||||
form.value.middle_name = schoolProfile.data?.middle_name || '';
|
||||
form.value.birth_date = schoolProfile.data?.birth_date || '';
|
||||
form.value.school = schoolProfile.data?.school || '';
|
||||
form.value.grade = schoolProfile.data?.grade || '';
|
||||
form.value.phone = schoolProfile.data?.phone || '';
|
||||
form.value.email_private = schoolProfile.data?.email_private || '';
|
||||
form.value.telegram = schoolProfile.data?.telegram || '';
|
||||
form.value.exams = schoolProfile.data?.exams ? schoolProfile.data.exams : [];
|
||||
form.value.learn_subjects = schoolProfile.data?.learn_subjects ? schoolProfile.data.learn_subjects : [];
|
||||
form.value.interests = schoolProfile.data?.interests || '';
|
||||
form.value.about_me = schoolProfile.data?.about_me || '';
|
||||
form.value.dreams = schoolProfile.data?.dreams || '';
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
|
||||
function toggleEdit() {
|
||||
editMode.value = !editMode.value;
|
||||
if (editMode.value) fillFormFromProfile();
|
||||
console.log('[DEBUG] Переключение режима редактирования:', { editMode: editMode.value });
|
||||
}
|
||||
|
||||
function validateExams(exams) {
|
||||
console.log('[DEBUG] Валидация exams:', { exams, validOptions: examOptions });
|
||||
return exams.every(exam => examOptions.includes(exam));
|
||||
}
|
||||
|
||||
function validateLearnSubjects(subjects) {
|
||||
console.log('[DEBUG] Валидация learn_subjects:', { subjects, validOptions: learnOptions });
|
||||
return subjects.every(subject => learnOptions.includes(subject));
|
||||
}
|
||||
|
||||
async function saveProfile() {
|
||||
console.log('[DEBUG] Сохранение профиля:', { form: form.value });
|
||||
saving.value = true;
|
||||
try {
|
||||
// Создаём копию данных формы
|
||||
const formData = { ...form.value };
|
||||
console.log('[DEBUG] Копия formData:', JSON.stringify(formData, null, 2));
|
||||
|
||||
// Обновление full_name в User, если нужно
|
||||
if (formData.first_name || formData.last_name) {
|
||||
const fullName = `${formData.first_name || ''} ${formData.last_name || ''}`.trim();
|
||||
console.log('[DEBUG] Обновление User.full_name:', { name: profile.data?.name, fullName });
|
||||
await createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
params: {
|
||||
doctype: 'User',
|
||||
name: profile.data?.name,
|
||||
fieldname: 'full_name',
|
||||
value: fullName,
|
||||
},
|
||||
}).submit();
|
||||
}
|
||||
|
||||
// Получаем docname
|
||||
let docname = '';
|
||||
try {
|
||||
await schoolProfile.reload();
|
||||
console.log('[DEBUG] Schoolprofile:', { schoolProfile });
|
||||
docname = schoolProfile?.data?.name;
|
||||
console.log('[DEBUG] Выбранное имя документа:', docname);
|
||||
} catch (error) {
|
||||
console.log('[DEBUG] Ошибка загрузки schoolProfile, продолжаем с profile:', error.message);
|
||||
}
|
||||
|
||||
// Формируем payload из копии данных формы
|
||||
let payload = {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
user: profile.data?.name,
|
||||
first_name: formData.first_name,
|
||||
last_name: formData.last_name,
|
||||
middle_name: formData.middle_name,
|
||||
birth_date: formData.birth_date,
|
||||
school: formData.school || '',
|
||||
grade: formData.grade,
|
||||
phone: formData.phone,
|
||||
email_private: formData.email_private,
|
||||
telegram: formData.telegram,
|
||||
exams: Array.isArray(formData.exams) ? formData.exams.map(exam => ({ exam_subject: exam })) : [],
|
||||
learn_subjects: Array.isArray(formData.learn_subjects) ? formData.learn_subjects.map(subject => ({ learn_subject: subject })) : [],
|
||||
interests: formData.interests,
|
||||
about_me: formData.about_me,
|
||||
dreams: formData.dreams,
|
||||
last_updated: new Date().toISOString(),
|
||||
};
|
||||
console.log('[DEBUG] Сохранение Schoolchildren Profile (payload):', { docname, payload });
|
||||
|
||||
// Сохранение или создание документа
|
||||
if (docname) {
|
||||
await createResource({
|
||||
url: 'frappe.client.save',
|
||||
params: { doc: { ...schoolProfile.data, ...payload } },
|
||||
}).submit();
|
||||
} else {
|
||||
await createResource({
|
||||
url: 'frappe.client.insert',
|
||||
params: { doc: payload },
|
||||
}).submit();
|
||||
}
|
||||
|
||||
editMode.value = false;
|
||||
schoolProfileNotFound.value = false;
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint('Профиль сохранён');
|
||||
console.log('[DEBUG] Профиль успешно сохранён');
|
||||
} catch (e) {
|
||||
console.error('[DEBUG] Ошибка при сохранении профиля:', e);
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: (e && e.message) || 'Ошибка при сохранении',
|
||||
indicator: 'red',
|
||||
});
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
await schoolProfile.reload();
|
||||
}
|
||||
|
||||
const schoolQuery = ref('');
|
||||
const schoolResults = ref([]);
|
||||
|
||||
async function searchSchool(q) {
|
||||
if (!q) {
|
||||
schoolResults.value = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log('[DEBUG] Поиск школы:', { query: q });
|
||||
const res = await createResource({
|
||||
url: 'frappe.client.get_list',
|
||||
params: {
|
||||
doctype: 'Schools',
|
||||
fields: ['school', 'address'],
|
||||
filters: [['school', 'like', '%' + q + '%']],
|
||||
limit_page_length: 20,
|
||||
},
|
||||
}).submit();
|
||||
schoolResults.value = res || [];
|
||||
console.log('[DEBUG] Результаты поиска школы:', schoolResults.value);
|
||||
} catch (e) {
|
||||
schoolResults.value = [];
|
||||
console.error('[DEBUG] Ошибка поиска школы:', e);
|
||||
}
|
||||
}
|
||||
|
||||
const debouncedSearchSchool = debounce(() => searchSchool(schoolQuery.value), 300);
|
||||
|
||||
function selectSchool(s) {
|
||||
form.value.school = s.school;
|
||||
//form.value.school_name = s.school_name;
|
||||
schoolResults.value = [];
|
||||
schoolQuery.value = s.school;
|
||||
console.log('[DEBUG] Выбрана школа:', { school: s });
|
||||
console.log('[DEBUG] Форма после заполнения:', JSON.stringify(form.value, null, 2));
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('[DEBUG] Компонент смонтирован:', {
|
||||
propsUsername: props.username,
|
||||
sessionUsername: $user.data?.username,
|
||||
user: user,
|
||||
$user: $user.data,
|
||||
});
|
||||
if ($user.data) {
|
||||
console.log('[DEBUG] Запуск profile.reload()');
|
||||
profile.reload();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.username,
|
||||
(newUsername, oldUsername) => {
|
||||
console.log('[DEBUG] Изменение props.username:', { old: oldUsername, new: newUsername });
|
||||
profile.reload();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => profile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение profile.data:', { old: oldData, new: newData });
|
||||
if (newData) {
|
||||
console.log('[DEBUG] Запуск schoolProfile.reload()');
|
||||
schoolProfile.reload();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => schoolProfile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение schoolProfile.data:', { old: oldData, new: newData });
|
||||
if (newData && !editMode.value && !schoolProfileNotFound.value) {
|
||||
console.log('[DEBUG] Заполнение формы из schoolProfile');
|
||||
fillFormFromProfile();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => effectiveUsername.value,
|
||||
(newUsername) => {
|
||||
console.log('[DEBUG] Изменение effectiveUsername для schoolProfile:', newUsername);
|
||||
schoolProfile.update({
|
||||
params: {
|
||||
doctype: 'Schoolchildren Profile',
|
||||
filters: { user: newUsername },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
1133
frontend/src/pages/StudentProfile.vue
Normal file
1133
frontend/src/pages/StudentProfile.vue
Normal file
File diff suppressed because it is too large
Load Diff
7
frontend/src/pages/Test.vue
Normal file
7
frontend/src/pages/Test.vue
Normal file
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<div class="min-h-screen p-6">
|
||||
<div class="text-center mb-8">
|
||||
<h1 class="text-3xl font-bold text-gray-800 mb-2">Тестовая страница</h1>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -9,6 +9,43 @@ const routes = [
|
||||
name: 'Home',
|
||||
component: () => import('@/pages/Home/Home.vue'),
|
||||
},
|
||||
//Test of page
|
||||
{
|
||||
path: '/test',
|
||||
name: 'Test',
|
||||
component: () => import('@/pages/Test.vue'),
|
||||
},
|
||||
{
|
||||
path: '/schoolchildren',
|
||||
name: 'SchoolchildrenProfile',
|
||||
component: () => import('@/pages/SchoolchildrenProfile.vue'),
|
||||
},
|
||||
{
|
||||
path: '/student',
|
||||
name: 'StudentProfile',
|
||||
component: () => import('@/pages/StudentProfile.vue'),
|
||||
},
|
||||
{
|
||||
path: '/coursecreator',
|
||||
name: 'CourseCreatorProfile',
|
||||
component: () => import('@/pages/CourseCreatorProfile.vue'),
|
||||
},
|
||||
{
|
||||
path: '/parent',
|
||||
name: 'ParentProfile',
|
||||
component: () => import('@/pages/ParentProfile.vue'),
|
||||
},
|
||||
{
|
||||
path: '/mypoints',
|
||||
name: 'MyPoints',
|
||||
component: () => import('@/pages/MyPoints.vue'),
|
||||
},
|
||||
{
|
||||
path: '/leaderboard',
|
||||
name: 'LeaderBoard',
|
||||
component: () => import('@/pages/LeaderBoard.vue'),
|
||||
},
|
||||
// End of test of page
|
||||
{
|
||||
path: '/courses',
|
||||
name: 'Courses',
|
||||
|
||||
@@ -54,16 +54,6 @@ export const sessionStore = defineStore('lms-session', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const livecodeURL = createResource({
|
||||
url: 'frappe.client.get_single_value',
|
||||
params: {
|
||||
doctype: 'LMS Settings',
|
||||
field: 'livecode_url',
|
||||
},
|
||||
cache: 'livecodeURL',
|
||||
auto: user.value ? true : false,
|
||||
})
|
||||
|
||||
return {
|
||||
user,
|
||||
isLoggedIn,
|
||||
@@ -71,6 +61,5 @@ export const sessionStore = defineStore('lms-session', () => {
|
||||
logout,
|
||||
brand,
|
||||
branding,
|
||||
livecodeURL,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -21,17 +21,41 @@ export const useSettings = defineStore('settings', () => {
|
||||
cache: ['preventSkippingVideos'],
|
||||
})
|
||||
|
||||
const contactUsEmail = createResource({
|
||||
url: 'lms.lms.api.get_lms_setting',
|
||||
params: { field: 'contact_us_email' },
|
||||
auto: true,
|
||||
cache: ['contactUsEmail'],
|
||||
})
|
||||
|
||||
const contactUsURL = createResource({
|
||||
url: 'lms.lms.api.get_lms_setting',
|
||||
params: { field: 'contact_us_url' },
|
||||
auto: true,
|
||||
cache: ['contactUsURL'],
|
||||
})
|
||||
|
||||
const sidebarSettings = createResource({
|
||||
url: 'lms.lms.api.get_sidebar_settings',
|
||||
cache: 'Sidebar Settings',
|
||||
auto: false,
|
||||
})
|
||||
|
||||
const livecodeURL = createResource({
|
||||
url: 'lms.lms.api.get_lms_setting',
|
||||
params: { field: 'livecode_url' },
|
||||
auto: true,
|
||||
cache: ['livecodeURL'],
|
||||
})
|
||||
|
||||
return {
|
||||
isSettingsOpen,
|
||||
activeTab,
|
||||
allowGuestAccess,
|
||||
preventSkippingVideos,
|
||||
contactUsEmail,
|
||||
contactUsURL,
|
||||
sidebarSettings,
|
||||
livecodeURL,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -239,6 +239,15 @@ export function getEditorTools() {
|
||||
'https://codesandbox.io/embed/<%= remote_id %>?view=editor+%2B+preview&module=%2Findex.html',
|
||||
html: "<iframe style='width: 100%; height: 500px; border: 0; border-radius: 4px; overflow: hidden;' sandbox='allow-mods allow-forms allow-popups allow-scripts allow-same-origin' frameborder='0' allowfullscreen='true'></iframe>",
|
||||
},
|
||||
rutube: {
|
||||
regex: /(?:https?:\/\/)?(?:www\.)?rutube\.ru\/(?:video\/|play\/embed\/)([^#&?=]*)/,
|
||||
embedUrl:
|
||||
'https://rutube.ru/play/embed/<%= remote_id %>',
|
||||
html: '<iframe style="width:100%; height: 30rem;" frameborder="0" allowfullscreen></iframe>',
|
||||
height: 320,
|
||||
width: 580,
|
||||
id: ([id]) => id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -422,7 +431,7 @@ export function getSidebarLinks() {
|
||||
activeFor: ['Batches', 'BatchDetail', 'Batch', 'BatchForm'],
|
||||
},
|
||||
{
|
||||
label: 'Certified Members',
|
||||
label: 'Certifications',
|
||||
icon: 'GraduationCap',
|
||||
to: 'CertifiedParticipants',
|
||||
activeFor: ['CertifiedParticipants'],
|
||||
|
||||
@@ -33,30 +33,7 @@ export default defineConfig({
|
||||
cleanupOutdatedCaches: true,
|
||||
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
|
||||
},
|
||||
manifest: {
|
||||
display: 'standalone',
|
||||
name: 'Learning',
|
||||
short_name: 'Learning',
|
||||
start_url: '/lms',
|
||||
description:
|
||||
'Easy to use, 100% open source Learning Management System',
|
||||
theme_color: '#0f7159',
|
||||
background_color: '#ffffff',
|
||||
icons: [
|
||||
{
|
||||
src: '/assets/lms/frontend/manifest/manifest-icon-192.maskable.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable any',
|
||||
},
|
||||
{
|
||||
src: '/assets/lms/frontend/manifest/manifest-icon-512.maskable.png',
|
||||
sizes: '512x512',
|
||||
type: 'image/png',
|
||||
purpose: 'maskable any',
|
||||
},
|
||||
],
|
||||
},
|
||||
manifest: false,
|
||||
}),
|
||||
],
|
||||
server: {
|
||||
|
||||
3852
frontend/yarn.lock
3852
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
__version__ = "2.35.0"
|
||||
__version__ = "2.39.2"
|
||||
|
||||
31
lms/activation.py
Normal file
31
lms/activation.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_site_info(site_info):
|
||||
# called via hook
|
||||
return {"activation": get_sales_data(site_info)}
|
||||
|
||||
|
||||
def get_sales_data(site_info):
|
||||
activation_level = site_info.get("activation", {}).get("activation_level", 0)
|
||||
sales_data = site_info.get("activation", {}).get("sales_data", [])
|
||||
doctypes = [
|
||||
"LMS Course",
|
||||
"Course Chapter",
|
||||
"Course Lesson",
|
||||
"LMS Batch",
|
||||
"LMS Enrollment",
|
||||
"LMS Quiz",
|
||||
"LMS Assignment",
|
||||
"LMS Programming Exercise",
|
||||
"LMS Program",
|
||||
"LMS Certificate",
|
||||
"LMS Certificate Request",
|
||||
"LMS Certificate Evaluation",
|
||||
]
|
||||
|
||||
for doctype in doctypes:
|
||||
count = frappe.db.count(doctype)
|
||||
sales_data.append({doctype: count})
|
||||
|
||||
return {"activation_level": activation_level, "sales_data": sales_data}
|
||||
@@ -105,7 +105,7 @@ doc_events = {
|
||||
"Notification Log": {"on_change": "lms.lms.utils.publish_notifications"},
|
||||
"User": {
|
||||
"validate": "lms.lms.user.validate_username_duplicates",
|
||||
"after_insert": "lms.lms.user.after_insert",
|
||||
#"after_insert": "lms.lms.user.after_insert",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ lms_markdown_macro_renderers = {
|
||||
"Exercise": "lms.plugins.exercise_renderer",
|
||||
"Quiz": "lms.plugins.quiz_renderer",
|
||||
"YouTubeVideo": "lms.plugins.youtube_video_renderer",
|
||||
"RuTubeVideo": "lms.plugins.rutube_video_renderer",
|
||||
"Video": "lms.plugins.video_renderer",
|
||||
"Assignment": "lms.plugins.assignment_renderer",
|
||||
"Embed": "lms.plugins.embed_renderer",
|
||||
@@ -240,6 +241,8 @@ signup_form_template = "lms.plugins.show_custom_signup"
|
||||
|
||||
on_login = "lms.lms.user.on_login"
|
||||
|
||||
get_site_info = "lms.activation.get_site_info"
|
||||
|
||||
add_to_apps_screen = [
|
||||
{
|
||||
"name": "lms",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"country",
|
||||
"column_break_5",
|
||||
"type",
|
||||
"work_mode",
|
||||
"status",
|
||||
"disabled",
|
||||
"section_break_6",
|
||||
@@ -119,6 +120,12 @@
|
||||
"label": "Country",
|
||||
"options": "Country",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "work_mode",
|
||||
"fieldtype": "Select",
|
||||
"label": "Work Mode",
|
||||
"options": "\nRemote\nHybrid\nOn-site"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
@@ -130,8 +137,8 @@
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2025-04-24 14:34:35.920242",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"modified": "2025-09-24 15:32:49.030004",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Job",
|
||||
"name": "Job Opportunity",
|
||||
"owner": "Administrator",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import add_months, get_link_to_form, getdate
|
||||
from frappe.utils import add_months, get_link_to_form, getdate, validate_url
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
||||
from lms.lms.utils import generate_slug, validate_image
|
||||
@@ -16,7 +16,7 @@ class JobOpportunity(Document):
|
||||
self.company_logo = validate_image(self.company_logo)
|
||||
|
||||
def validate_urls(self):
|
||||
frappe.utils.validate_url(self.company_website, True)
|
||||
validate_url(self.company_website, True)
|
||||
|
||||
def autoname(self):
|
||||
if not self.name:
|
||||
|
||||
101
lms/lms/api.py
101
lms/lms/api.py
@@ -25,6 +25,7 @@ from frappe.utils import (
|
||||
get_datetime,
|
||||
now,
|
||||
)
|
||||
from frappe.utils.response import Response
|
||||
|
||||
from lms.lms.doctype.course_lesson.course_lesson import save_progress
|
||||
from lms.lms.utils import get_average_rating, get_lesson_count
|
||||
@@ -252,6 +253,7 @@ def get_job_details(job):
|
||||
"location",
|
||||
"country",
|
||||
"type",
|
||||
"work_mode",
|
||||
"company_name",
|
||||
"company_logo",
|
||||
"company_website",
|
||||
@@ -278,6 +280,7 @@ def get_job_opportunities(filters=None, orFilters=None):
|
||||
"location",
|
||||
"country",
|
||||
"type",
|
||||
"work_mode",
|
||||
"company_name",
|
||||
"company_logo",
|
||||
"name",
|
||||
@@ -467,16 +470,22 @@ def get_assigned_badges(member):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_users():
|
||||
frappe.only_for(["Moderator", "Course Creator", "Batch Evaluator"])
|
||||
users = frappe.get_all(
|
||||
"User",
|
||||
{
|
||||
"enabled": 1,
|
||||
},
|
||||
["name", "full_name", "user_image"],
|
||||
)
|
||||
frappe.only_for(["Moderator", "Course Creator", "Batch Evaluator", "LMS Student", "LMS Schoolchild", "Parent"])
|
||||
users = frappe.get_all(
|
||||
"User",
|
||||
{"enabled": 1},
|
||||
["name", "full_name", "user_image", "email", "username"]
|
||||
)
|
||||
|
||||
return {user.name: user for user in users}
|
||||
for user in users:
|
||||
roles = frappe.get_all(
|
||||
"Has Role",
|
||||
filters={"parent": user.name},
|
||||
fields=["role"]
|
||||
)
|
||||
user["roles"] = [role["role"] for role in roles]
|
||||
|
||||
return users
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
@@ -504,7 +513,7 @@ def get_sidebar_settings():
|
||||
items = [
|
||||
"courses",
|
||||
"batches",
|
||||
"certified_members",
|
||||
"certifications",
|
||||
"jobs",
|
||||
"statistics",
|
||||
"notifications",
|
||||
@@ -823,7 +832,6 @@ def get_count(doctype, filters):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_payment_gateway_details(payment_gateway):
|
||||
fields = []
|
||||
gateway = frappe.get_doc("Payment Gateway", payment_gateway)
|
||||
|
||||
if gateway.gateway_controller is None:
|
||||
@@ -843,15 +851,30 @@ def get_payment_gateway_details(payment_gateway):
|
||||
except Exception:
|
||||
frappe.throw(_("{0} Settings not found").format(payment_gateway))
|
||||
|
||||
gateway_fields = get_transformed_fields(meta, data)
|
||||
|
||||
return {
|
||||
"fields": gateway_fields,
|
||||
"data": data,
|
||||
"doctype": doctype,
|
||||
"docname": docname,
|
||||
}
|
||||
|
||||
|
||||
def get_transformed_fields(meta, data=None):
|
||||
transformed_fields = []
|
||||
for row in meta:
|
||||
if row.fieldtype not in ["Column Break", "Section Break"]:
|
||||
if row.fieldtype in ["Attach", "Attach Image"]:
|
||||
fieldtype = "Upload"
|
||||
data[row.fieldname] = get_file_info(data.get(row.fieldname))
|
||||
if data and data.get(row.fieldname):
|
||||
data[row.fieldname] = get_file_info(data.get(row.fieldname))
|
||||
elif row.fieldtype == "Check":
|
||||
fieldtype = "checkbox"
|
||||
else:
|
||||
fieldtype = row.fieldtype
|
||||
|
||||
fields.append(
|
||||
transformed_fields.append(
|
||||
{
|
||||
"label": row.label,
|
||||
"name": row.fieldname,
|
||||
@@ -859,12 +882,19 @@ def get_payment_gateway_details(payment_gateway):
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"fields": fields,
|
||||
"data": data,
|
||||
"doctype": doctype,
|
||||
"docname": docname,
|
||||
}
|
||||
return transformed_fields
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_new_gateway_fields(doctype):
|
||||
try:
|
||||
meta = frappe.get_meta(doctype).fields
|
||||
except Exception:
|
||||
frappe.throw(_("{0} not found").format(doctype))
|
||||
|
||||
transformed_fields = get_transformed_fields(meta)
|
||||
|
||||
return transformed_fields
|
||||
|
||||
|
||||
def update_course_statistics():
|
||||
@@ -1625,3 +1655,36 @@ def get_progress_distribution(progressList):
|
||||
]
|
||||
|
||||
return distribution
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_pwa_manifest():
|
||||
title = frappe.db.get_single_value("Website Settings", "app_name") or "Frappe Learning"
|
||||
banner_image = frappe.db.get_single_value("Website Settings", "banner_image")
|
||||
|
||||
manifest = {
|
||||
"name": title,
|
||||
"short_name": title,
|
||||
"description": "Easy to use, 100% open source Learning Management System",
|
||||
"start_url": "/lms",
|
||||
"icons": [
|
||||
{
|
||||
"src": banner_image or "/assets/lms/frontend/manifest/manifest-icon-192.maskable.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
return Response(json.dumps(manifest), status=200, content_type="application/manifest+json")
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_profile_details(username):
|
||||
return frappe.db.get_value(
|
||||
"User",
|
||||
{"username": username},
|
||||
["full_name", "name", "username", "user_image", "bio", "headline", "cover_image"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -4,16 +4,17 @@
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
from lms.lms.api import update_course_statistics
|
||||
from lms.lms.utils import get_course_progress
|
||||
from lms.lms.utils import get_course_progress, get_lesson_count
|
||||
|
||||
|
||||
class CourseChapter(Document):
|
||||
def on_update(self):
|
||||
self.recalculate_course_progress()
|
||||
update_course_statistics()
|
||||
self.update_lesson_count()
|
||||
frappe.enqueue(method=self.recalculate_course_progress, queue="short", timeout=300, is_async=True)
|
||||
|
||||
def recalculate_course_progress(self):
|
||||
"""Recalculate course progress if a new lesson is added or removed"""
|
||||
previous_lessons = self.get_doc_before_save() and self.get_doc_before_save().as_dict().lessons
|
||||
current_lessons = self.lessons
|
||||
|
||||
@@ -22,3 +23,7 @@ class CourseChapter(Document):
|
||||
for enrollment in enrolled_members:
|
||||
new_progress = get_course_progress(self.course, enrollment.member)
|
||||
frappe.db.set_value("LMS Enrollment", enrollment.name, "progress", new_progress)
|
||||
|
||||
def update_lesson_count(self):
|
||||
"""Update lesson count in the course"""
|
||||
frappe.db.set_value("LMS Course", self.course, "lessons", get_lesson_count(self.course))
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"instructor_notes",
|
||||
"section_break_6",
|
||||
"youtube",
|
||||
"rutube",
|
||||
"column_break_9",
|
||||
"quiz_id",
|
||||
"section_break_16",
|
||||
@@ -104,6 +105,12 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "YouTube Video URL"
|
||||
},
|
||||
{
|
||||
"description": "RuTube Video will appear at the top of the lesson.",
|
||||
"fieldname": "rutube",
|
||||
"fieldtype": "Data",
|
||||
"label": "RuTube Video URL"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_16",
|
||||
"fieldtype": "Section Break",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user