diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/microsoft_calendar/static | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/microsoft_calendar/static')
| -rw-r--r-- | addons/microsoft_calendar/static/description/icon.png | bin | 0 -> 10162 bytes | |||
| -rw-r--r-- | addons/microsoft_calendar/static/description/icon.svg | 22 | ||||
| -rw-r--r-- | addons/microsoft_calendar/static/src/img/calendar_outlook_32.png | bin | 0 -> 450 bytes | |||
| -rw-r--r-- | addons/microsoft_calendar/static/src/js/microsoft_calendar.js | 219 | ||||
| -rw-r--r-- | addons/microsoft_calendar/static/src/js/microsoft_calendar_popover.js | 34 | ||||
| -rw-r--r-- | addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss | 14 | ||||
| -rw-r--r-- | addons/microsoft_calendar/static/src/xml/microsoft_calendar_popover.xml | 8 |
7 files changed, 297 insertions, 0 deletions
diff --git a/addons/microsoft_calendar/static/description/icon.png b/addons/microsoft_calendar/static/description/icon.png Binary files differnew file mode 100644 index 00000000..b8734363 --- /dev/null +++ b/addons/microsoft_calendar/static/description/icon.png diff --git a/addons/microsoft_calendar/static/description/icon.svg b/addons/microsoft_calendar/static/description/icon.svg new file mode 100644 index 00000000..6056dc85 --- /dev/null +++ b/addons/microsoft_calendar/static/description/icon.svg @@ -0,0 +1,22 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="70" height="70" viewBox="0 0 70 70"> + <defs> + <path id="icon-a" d="M4,5.35309892e-14 C36.4160122,9.87060235e-15 58.0836068,-3.97961823e-14 65,5.07020818e-14 C69,6.733808e-14 70,1 70,5 C70,43.0488877 70,62.4235458 70,65 C70,69 69,70 65,70 C61,70 9,70 4,70 C1,70 7.10542736e-15,69 7.10542736e-15,65 C7.25721566e-15,62.4676575 3.83358709e-14,41.8005206 3.60818146e-14,5 C-1.13686838e-13,1 1,5.75716207e-14 4,5.35309892e-14 Z"/> + <linearGradient id="icon-c" x1="100%" x2="0%" y1="0%" y2="100%"> + <stop offset="0%" stop-color="#94B6C8"/> + <stop offset="100%" stop-color="#6A9EBA"/> + </linearGradient> + </defs> + <g fill="none" fill-rule="evenodd"> + <mask id="icon-b" fill="#fff"> + <use xlink:href="#icon-a"/> + </mask> + <g mask="url(#icon-b)"> + <rect width="70" height="70" fill="url(#icon-c)"/> + <path fill="#FFF" fill-opacity=".383" d="M4,1.8 L65,1.8 C67.6666667,1.8 69.3333333,1.13333333 70,-0.2 C70,2.46666667 70,3.46666667 70,2.8 L1.10547097e-14,2.8 C-1.65952376e-14,3.46666667 -2.9161925e-14,2.46666667 -2.66453526e-14,-0.2 C0.666666667,1.13333333 2,1.8 4,1.8 Z" transform="matrix(1 0 0 -1 0 2.8)"/> + <path fill="#393939" d="M4,53 C2,53 -7.10542736e-15,52.8543956 0,48.9230769 L2.12440903e-16,23.797368 L15,0 L54,0 L54,26.3118387 L57.7908529,26.3118387 L59,37.7115385 L49.1366936,53 L4,53 Z" opacity=".324" transform="translate(0 16)"/> + <path fill="#000" fill-opacity=".383" d="M4,4 L65,4 C67.6666667,4 69.3333333,3 70,1 C70,3.66666667 70,5 70,5 L1.77635684e-15,5 C1.77635684e-15,5 1.77635684e-15,3.66666667 1.77635684e-15,1 C0.666666667,3 2,4 4,4 Z" transform="translate(0 65)"/> + <path fill="#000" fill-rule="nonzero" d="M42.0955645,41.4315062 L42.0955645,28.7560864 L40.3833955,28.7560864 C40.2604632,29.4411054 40.0321745,30.0062307 39.6985283,30.4514643 C39.3648683,30.8967319 38.9521929,31.2477943 38.4604987,31.5046545 C37.986355,31.7615447 37.4507537,31.9413579 36.8536946,32.0440934 C36.2566271,32.1297334 35.6420039,32.1725451 35.0098218,32.1725307 L35.0098218,33.9192846 L39.8565751,33.9192846 L39.8565751,46.9685596 L41.0044957,46.9685596 C41.0029977,46.9790279 41.0014988,46.9895081 41,47 C41.6666667,47 42,47.3333333 42,48 C42,48.6666667 42,49 42,49 C40.6666667,49.6666667 40,50.3333333 40,51 C40,51.5412134 40.219684,52.3021107 40.6590519,53.282692 L15,53.282692 L15,24.0484615 L54.763358,24.0484615 L54.763358,37 C51.587786,37 49.6666667,37 49,37 C48.3333333,37 48,37.3333333 48,38 C48,38 48,38.3333333 48,39 C48,39.6666667 47.3333333,40 46,40 C44.6666667,40 43.6666667,40 43,40 C42.6985215,40 42.397043,40.4771687 42.0955645,41.4315062 Z M54.763358,23.0403846 L15,23.0403846 L15,18 L54.763358,18 L54.763358,23.0403846 Z M59.1120093,49.6163985 L60.7668484,50.585058 C60.9558409,50.6956709 61.043561,50.9244177 60.9788291,51.1357594 C60.5489654,52.5392703 59.8150519,53.807242 58.8551784,54.8603674 C58.7072273,55.022782 58.4680825,55.059636 58.279231,54.9491254 L56.6256345,53.9806234 C55.9298948,54.5851374 55.1300224,55.0541223 54.2662772,55.3639727 L54.2662772,57.3006617 C54.2662804,57.5219079 54.1150225,57.7135885 53.9021551,57.7620931 C52.5447646,58.0712105 51.0869171,58.0871979 49.661028,57.7623688 C49.4478436,57.7138157 49.2958963,57.5223205 49.2958963,57.3007404 L49.2958963,55.3639727 C48.4321428,55.0541404 47.6322673,54.5851537 46.936539,53.9806234 L45.2829425,54.9491254 C45.0940909,55.059636 44.8549462,55.022782 44.7069951,54.8603674 C43.7471604,53.807242 43.0132081,52.5392703 42.5833444,51.1357594 C42.5186125,50.9244571 42.6063326,50.6957102 42.795325,50.585058 L44.450203,49.6163985 C44.2839859,48.7026748 44.2839859,47.7658257 44.450203,46.852102 L42.7953639,45.8834424 C42.6063714,45.7728296 42.5186513,45.5440828 42.5833832,45.332741 C43.0132469,43.9292302 43.7471604,42.6612585 44.7070339,41.6081331 C44.8549851,41.4457185 45.0941298,41.4088644 45.2829813,41.5193751 L46.9365778,42.4878771 C47.6323176,41.8833631 48.4321899,41.4143782 49.2959351,41.1045278 L49.2959351,39.1677994 C49.2959319,38.9465532 49.4471898,38.7548726 49.6600572,38.706368 C51.0174478,38.3972506 52.4752952,38.3812631 53.9011843,38.7060923 C54.1143687,38.7546454 54.266316,38.9461406 54.266316,39.1677207 L54.266316,41.1044884 C55.1300695,41.4143207 55.929945,41.8833074 56.6256733,42.4878377 L58.2792698,41.5193357 C58.4681214,41.4088251 58.7072661,41.4456791 58.8552172,41.6080937 C59.8150519,42.6612191 60.5490043,43.9291908 60.9788679,45.3327017 C61.0435999,45.544004 60.9558797,45.7727509 60.7668873,45.8834031 L59.1120093,46.8520626 C59.2782268,47.7657995 59.2782268,48.7026616 59.1120093,49.6163985 Z M54.8876185,48.2342305 C54.8876185,46.497188 53.4940371,45.0839902 51.7811062,45.0839902 C50.0681752,45.0839902 48.6745938,46.497188 48.6745938,48.2342305 C48.6745938,49.9712731 50.0681752,51.3844709 51.7811062,51.3844709 C53.4940371,51.3844709 54.8876185,49.9712731 54.8876185,48.2342305 Z M25.3383523,20.6895722 C25.3383523,19.7564466 24.5910361,19 23.6691756,19 C22.7473152,19 22,19.7564466 22,20.6895722 C22,21.6226969 22.7473152,22.3791434 23.6691756,22.3791434 C24.5910361,22.3791434 25.3383523,21.6226969 25.3383523,20.6895722 Z M48.3383523,20.6895722 C48.3383523,19.7564466 47.5910361,19 46.6691756,19 C45.7473152,19 45,19.7564466 45,20.6895722 C45,21.6226969 45.7473152,22.3791434 46.6691756,22.3791434 C47.5910361,22.3791434 48.3383523,21.6226969 48.3383523,20.6895722 Z M26.4684862,38.4146042 C26.856901,38.3632372 27.2695974,38.3375505 27.7065763,38.3375419 C28.2082784,38.3375505 28.685711,38.4146128 29.1388753,38.56873 C29.5920244,38.705738 29.9804432,38.9283634 30.3041359,39.2366062 C30.6278103,39.5277389 30.8867565,39.8959263 31.0809766,40.3411707 C31.2751764,40.7693028 31.3722814,41.2659282 31.3722915,41.8310479 C31.3722814,42.3790542 31.2670842,42.8756796 31.0567001,43.3209262 C30.86248,43.749055 30.5954416,44.1172436 30.2555839,44.4254907 C29.9157069,44.716619 29.5191949,44.947806 29.0660468,45.1190547 C28.6128825,45.2731815 28.1354499,45.3502438 27.6337468,45.3502428 C26.4522968,45.3502438 25.5540767,44.9820564 24.9390823,44.2456783 C24.3240808,43.4921803 24.0003972,42.5246163 23.9680316,41.3429851 L21.9045489,41.3429851 C21.8883645,42.2848667 22.009746,43.1239918 22.2686932,43.8603645 C22.5438228,44.5967437 22.9322426,45.221807 23.4339538,45.7355554 C23.9356609,46.2321829 24.5425662,46.6174956 25.2546737,46.8914955 C25.966772,47.1483714 26.7597961,47.2768082 27.6337468,47.2768093 C28.4429491,47.2768082 29.2036045,47.156934 29.915716,46.9171833 C30.6439946,46.6774327 31.2751764,46.3263705 31.8092643,45.8639933 C32.343331,45.4016194 32.7641185,44.8279318 33.0716299,44.1429281 C33.3953013,43.4408047 33.5571425,42.635929 33.5571547,41.7282978 C33.5571425,40.6323023 33.2981963,39.6818635 32.780315,38.8769803 C32.2785937,38.0721121 31.501755,37.5497989 30.4497938,37.3100397 L30.4497938,37.2586641 C31.1133351,36.9332983 31.6716884,36.4537981 32.1248557,35.8201615 C32.5941851,35.1694222 32.8288558,34.4416088 32.828867,33.6367202 C32.8288558,32.797607 32.69129,32.0697936 32.4161706,31.4532779 C32.1572132,30.8367933 31.7930699,30.3316054 31.3237385,29.937713 C30.8543879,29.5438538 30.2960346,29.2527287 29.6486766,29.0643354 C29.0174867,28.8588534 28.3296598,28.7561033 27.5851948,28.7560851 C26.7274274,28.7561033 25.966772,28.9016664 25.3032256,29.1927733 C24.6558555,29.4839167 24.1136865,29.8863545 23.6767167,30.4000879 C23.2397419,30.9138557 22.899874,31.5303563 22.6571131,32.2495921 C22.4305335,32.9688579 22.3010609,33.765171 22.2686932,34.6385346 L24.332176,34.6385346 C24.3321719,34.1076707 24.3969093,33.6024827 24.5263859,33.1229686 C24.6558555,32.6434824 24.8500654,32.2239193 25.1090157,31.8642784 C25.3841422,31.5046685 25.7240101,31.222106 26.1286194,31.0165897 C26.5332175,30.7939804 27.0187423,30.6826676 27.5851948,30.6826515 C28.4591324,30.6826676 29.1874202,30.9309809 29.7700581,31.4275901 C30.3526797,31.9242316 30.6439946,32.652045 30.6440038,33.6110324 C30.6439946,34.1076707 30.5549808,34.5443589 30.3769643,34.9210972 C30.1989296,35.2807349 29.9561677,35.5889853 29.6486766,35.8458493 C29.3573536,36.0856106 29.0093946,36.2739857 28.6047975,36.4109754 C28.2163705,36.5308604 27.8036742,36.5907986 27.3667084,36.5907879 C27.2210444,36.5907986 27.0753874,36.5907986 26.9297356,36.5907879 C26.7840726,36.5907986 26.6303224,36.582236 26.4684862,36.5651001 L26.4684862,38.4146042 Z M13.808,57.508 L12.524,57.508 L12.524,56.716 L16.034,56.716 L16.034,57.508 L14.75,57.508 L14.75,61 L13.808,61 L13.808,57.508 Z M16.526,56.716 L17.852,56.716 L18.854,59.662 L18.866,59.662 L19.814,56.716 L21.14,56.716 L21.14,61 L20.258,61 L20.258,57.964 L20.246,57.964 L19.196,61 L18.47,61 L17.42,57.994 L17.408,57.994 L17.408,61 L16.526,61 L16.526,56.716 Z" opacity=".3"/> + <path fill="#FFF" fill-rule="nonzero" d="M42.0955645,39.4315062 L42.0955645,26.7560864 L40.3833955,26.7560864 C40.2604632,27.4411054 40.0321745,28.0062307 39.6985283,28.4514643 C39.3648683,28.8967319 38.9521929,29.2477943 38.4604987,29.5046545 C37.986355,29.7615447 37.4507537,29.9413579 36.8536946,30.0440934 C36.2566271,30.1297334 35.6420039,30.1725451 35.0098218,30.1725307 L35.0098218,31.9192846 L39.8565751,31.9192846 L39.8565751,44.9685596 L41.0044957,44.9685596 C41.0029977,44.9790279 41.0014988,44.9895081 41,45 C41.6666667,45 42,45.3333333 42,46 C42,46.6666667 42,47 42,47 C40.6666667,47.6666667 40,48.3333333 40,49 C40,49.5412134 40.219684,50.3021107 40.6590519,51.282692 L15,51.282692 L15,22.0484615 L54.763358,22.0484615 L54.763358,35 C51.587786,35 49.6666667,35 49,35 C48.3333333,35 48,35.3333333 48,36 C48,36 48,36.3333333 48,37 C48,37.6666667 47.3333333,38 46,38 C44.6666667,38 43.6666667,38 43,38 C42.6985215,38 42.397043,38.4771687 42.0955645,39.4315062 Z M54.763358,21.0403846 L15,21.0403846 L15,16 L54.763358,16 L54.763358,21.0403846 Z M59.1120093,47.6163985 L60.7668484,48.585058 C60.9558409,48.6956709 61.043561,48.9244177 60.9788291,49.1357594 C60.5489654,50.5392703 59.8150519,51.807242 58.8551784,52.8603674 C58.7072273,53.022782 58.4680825,53.059636 58.279231,52.9491254 L56.6256345,51.9806234 C55.9298948,52.5851374 55.1300224,53.0541223 54.2662772,53.3639727 L54.2662772,55.3006617 C54.2662804,55.5219079 54.1150225,55.7135885 53.9021551,55.7620931 C52.5447646,56.0712105 51.0869171,56.0871979 49.661028,55.7623688 C49.4478436,55.7138157 49.2958963,55.5223205 49.2958963,55.3007404 L49.2958963,53.3639727 C48.4321428,53.0541404 47.6322673,52.5851537 46.936539,51.9806234 L45.2829425,52.9491254 C45.0940909,53.059636 44.8549462,53.022782 44.7069951,52.8603674 C43.7471604,51.807242 43.0132081,50.5392703 42.5833444,49.1357594 C42.5186125,48.9244571 42.6063326,48.6957102 42.795325,48.585058 L44.450203,47.6163985 C44.2839859,46.7026748 44.2839859,45.7658257 44.450203,44.852102 L42.7953639,43.8834424 C42.6063714,43.7728296 42.5186513,43.5440828 42.5833832,43.332741 C43.0132469,41.9292302 43.7471604,40.6612585 44.7070339,39.6081331 C44.8549851,39.4457185 45.0941298,39.4088644 45.2829813,39.5193751 L46.9365778,40.4878771 C47.6323176,39.8833631 48.4321899,39.4143782 49.2959351,39.1045278 L49.2959351,37.1677994 C49.2959319,36.9465532 49.4471898,36.7548726 49.6600572,36.706368 C51.0174478,36.3972506 52.4752952,36.3812631 53.9011843,36.7060923 C54.1143687,36.7546454 54.266316,36.9461406 54.266316,37.1677207 L54.266316,39.1044884 C55.1300695,39.4143207 55.929945,39.8833074 56.6256733,40.4878377 L58.2792698,39.5193357 C58.4681214,39.4088251 58.7072661,39.4456791 58.8552172,39.6080937 C59.8150519,40.6612191 60.5490043,41.9291908 60.9788679,43.3327017 C61.0435999,43.544004 60.9558797,43.7727509 60.7668873,43.8834031 L59.1120093,44.8520626 C59.2782268,45.7657995 59.2782268,46.7026616 59.1120093,47.6163985 Z M54.8876185,46.2342305 C54.8876185,44.497188 53.4940371,43.0839902 51.7811062,43.0839902 C50.0681752,43.0839902 48.6745938,44.497188 48.6745938,46.2342305 C48.6745938,47.9712731 50.0681752,49.3844709 51.7811062,49.3844709 C53.4940371,49.3844709 54.8876185,47.9712731 54.8876185,46.2342305 Z M25.3383523,18.6895722 C25.3383523,17.7564466 24.5910361,17 23.6691756,17 C22.7473152,17 22,17.7564466 22,18.6895722 C22,19.6226969 22.7473152,20.3791434 23.6691756,20.3791434 C24.5910361,20.3791434 25.3383523,19.6226969 25.3383523,18.6895722 Z M48.3383523,18.6895722 C48.3383523,17.7564466 47.5910361,17 46.6691756,17 C45.7473152,17 45,17.7564466 45,18.6895722 C45,19.6226969 45.7473152,20.3791434 46.6691756,20.3791434 C47.5910361,20.3791434 48.3383523,19.6226969 48.3383523,18.6895722 Z M26.4684862,36.4146042 C26.856901,36.3632372 27.2695974,36.3375505 27.7065763,36.3375419 C28.2082784,36.3375505 28.685711,36.4146128 29.1388753,36.56873 C29.5920244,36.705738 29.9804432,36.9283634 30.3041359,37.2366062 C30.6278103,37.5277389 30.8867565,37.8959263 31.0809766,38.3411707 C31.2751764,38.7693028 31.3722814,39.2659282 31.3722915,39.8310479 C31.3722814,40.3790542 31.2670842,40.8756796 31.0567001,41.3209262 C30.86248,41.749055 30.5954416,42.1172436 30.2555839,42.4254907 C29.9157069,42.716619 29.5191949,42.947806 29.0660468,43.1190547 C28.6128825,43.2731815 28.1354499,43.3502438 27.6337468,43.3502428 C26.4522968,43.3502438 25.5540767,42.9820564 24.9390823,42.2456783 C24.3240808,41.4921803 24.0003972,40.5246163 23.9680316,39.3429851 L21.9045489,39.3429851 C21.8883645,40.2848667 22.009746,41.1239918 22.2686932,41.8603645 C22.5438228,42.5967437 22.9322426,43.221807 23.4339538,43.7355554 C23.9356609,44.2321829 24.5425662,44.6174956 25.2546737,44.8914955 C25.966772,45.1483714 26.7597961,45.2768082 27.6337468,45.2768093 C28.4429491,45.2768082 29.2036045,45.156934 29.915716,44.9171833 C30.6439946,44.6774327 31.2751764,44.3263705 31.8092643,43.8639933 C32.343331,43.4016194 32.7641185,42.8279318 33.0716299,42.1429281 C33.3953013,41.4408047 33.5571425,40.635929 33.5571547,39.7282978 C33.5571425,38.6323023 33.2981963,37.6818635 32.780315,36.8769803 C32.2785937,36.0721121 31.501755,35.5497989 30.4497938,35.3100397 L30.4497938,35.2586641 C31.1133351,34.9332983 31.6716884,34.4537981 32.1248557,33.8201615 C32.5941851,33.1694222 32.8288558,32.4416088 32.828867,31.6367202 C32.8288558,30.797607 32.69129,30.0697936 32.4161706,29.4532779 C32.1572132,28.8367933 31.7930699,28.3316054 31.3237385,27.937713 C30.8543879,27.5438538 30.2960346,27.2527287 29.6486766,27.0643354 C29.0174867,26.8588534 28.3296598,26.7561033 27.5851948,26.7560851 C26.7274274,26.7561033 25.966772,26.9016664 25.3032256,27.1927733 C24.6558555,27.4839167 24.1136865,27.8863545 23.6767167,28.4000879 C23.2397419,28.9138557 22.899874,29.5303563 22.6571131,30.2495921 C22.4305335,30.9688579 22.3010609,31.765171 22.2686932,32.6385346 L24.332176,32.6385346 C24.3321719,32.1076707 24.3969093,31.6024827 24.5263859,31.1229686 C24.6558555,30.6434824 24.8500654,30.2239193 25.1090157,29.8642784 C25.3841422,29.5046685 25.7240101,29.222106 26.1286194,29.0165897 C26.5332175,28.7939804 27.0187423,28.6826676 27.5851948,28.6826515 C28.4591324,28.6826676 29.1874202,28.9309809 29.7700581,29.4275901 C30.3526797,29.9242316 30.6439946,30.652045 30.6440038,31.6110324 C30.6439946,32.1076707 30.5549808,32.5443589 30.3769643,32.9210972 C30.1989296,33.2807349 29.9561677,33.5889853 29.6486766,33.8458493 C29.3573536,34.0856106 29.0093946,34.2739857 28.6047975,34.4109754 C28.2163705,34.5308604 27.8036742,34.5907986 27.3667084,34.5907879 C27.2210444,34.5907986 27.0753874,34.5907986 26.9297356,34.5907879 C26.7840726,34.5907986 26.6303224,34.582236 26.4684862,34.5651001 L26.4684862,36.4146042 Z M13.808,55.508 L12.524,55.508 L12.524,54.716 L16.034,54.716 L16.034,55.508 L14.75,55.508 L14.75,59 L13.808,59 L13.808,55.508 Z M16.526,54.716 L17.852,54.716 L18.854,57.662 L18.866,57.662 L19.814,54.716 L21.14,54.716 L21.14,59 L20.258,59 L20.258,55.964 L20.246,55.964 L19.196,59 L18.47,59 L17.42,55.994 L17.408,55.994 L17.408,59 L16.526,59 L16.526,54.716 Z"/> + </g> + </g> +</svg> diff --git a/addons/microsoft_calendar/static/src/img/calendar_outlook_32.png b/addons/microsoft_calendar/static/src/img/calendar_outlook_32.png Binary files differnew file mode 100644 index 00000000..78553f07 --- /dev/null +++ b/addons/microsoft_calendar/static/src/img/calendar_outlook_32.png diff --git a/addons/microsoft_calendar/static/src/js/microsoft_calendar.js b/addons/microsoft_calendar/static/src/js/microsoft_calendar.js new file mode 100644 index 00000000..dab5def9 --- /dev/null +++ b/addons/microsoft_calendar/static/src/js/microsoft_calendar.js @@ -0,0 +1,219 @@ +odoo.define('microsoft_calendar.CalendarView', function (require) { +"use strict"; + +var core = require('web.core'); +var Dialog = require('web.Dialog'); +var framework = require('web.framework'); +const CalendarView = require('calendar.CalendarView'); +const CalendarRenderer = require('calendar.CalendarRenderer'); +const CalendarController = require('calendar.CalendarController'); +const CalendarModel = require('calendar.CalendarModel'); +const viewRegistry = require('web.view_registry'); +const session = require('web.session'); + +var _t = core._t; + +const MicrosoftCalendarModel = CalendarModel.include({ + + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + this.microsoft_is_sync = true; + this.microsoft_pending_sync = false; + }, + + /** + * @override + */ + __get: function () { + var result = this._super.apply(this, arguments); + result.microsoft_is_sync = this.microsoft_is_sync; + return result; + }, + + /** + * @override + * @returns {Promise} + */ + async _loadCalendar() { + const _super = this._super.bind(this); + // When the calendar synchronization takes some time, prevents retriggering the sync while navigating the calendar. + if (this.microsoft_pending_sync) { + return _super(...arguments); + } + try { + await Promise.race([ + new Promise(resolve => setTimeout(resolve, 1000)), + this._syncMicrosoftCalendar(true) + ]); + } catch (error) { + if (error.event) { + error.event.preventDefault(); + } + console.error("Could not synchronize Outlook events now.", error); + this.microsoft_pending_sync = false; + } + return _super(...arguments); + }, + + _syncMicrosoftCalendar(shadow = false) { + var self = this; + this.microsoft_pending_sync = true; + return this._rpc({ + route: '/microsoft_calendar/sync_data', + params: { + model: this.modelName, + fromurl: window.location.href, + } + }, {shadow}).then(function (result) { + if (result.status === "need_config_from_admin" || result.status === "need_auth") { + self.microsoft_is_sync = false; + } else if (result.status === "no_new_event_from_microsoft" || result.status === "need_refresh") { + self.microsoft_is_sync = true; + } + self.microsoft_pending_sync = false; + return result + }); + }, + + archiveRecords: function (ids, model) { + return this._rpc({ + model: model, + method: 'action_archive', + args: [ids], + context: session.user_context, + }); + }, +}); + +const MicrosoftCalendarController = CalendarController.include({ + custom_events: _.extend({}, CalendarController.prototype.custom_events, { + syncMicrosoftCalendar: '_onSyncMicrosoftCalendar', + archiveRecord: '_onArchiveRecord', + }), + + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Try to sync the calendar with Microsoft Calendar. According to the result + * from Microsoft API, this function may require an action of the user by the + * mean of a dialog. + * + * @private + * @returns {OdooEvent} event + */ + _onSyncMicrosoftCalendar: function (event) { + var self = this; + + return this.model._syncMicrosoftCalendar().then(function (o) { + if (o.status === "need_auth") { + Dialog.alert(self, _t("You will be redirected to Outlook to authorize the access to your calendar."), { + confirm_callback: function() { + framework.redirect(o.url); + }, + title: _t('Redirection'), + }); + } else if (o.status === "need_config_from_admin") { + if (!_.isUndefined(o.action) && parseInt(o.action)) { + Dialog.confirm(self, _t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), { + confirm_callback: function() { + self.do_action(o.action); + }, + title: _t('Configuration'), + }); + } else { + Dialog.alert(self, _t("An administrator needs to configure Outlook Synchronization before you can use it!"), { + title: _t('Configuration'), + }); + } + } else if (o.status === "need_refresh") { + self.reload(); + } + }).then(event.data.on_always, event.data.on_always); + }, + + _onArchiveRecord: function (ev) { + var self = this; + Dialog.confirm(this, _t("Are you sure you want to archive this record ?"), { + confirm_callback: function () { + self.model.archiveRecords([ev.data.id], self.modelName).then(function () { + self.reload(); + }); + } + }); + }, +}); + +const MicrosoftCalendarRenderer = CalendarRenderer.include({ + events: _.extend({}, CalendarRenderer.prototype.events, { + 'click .o_microsoft_sync_button': '_onSyncMicrosoftCalendar', + }), + custom_events: _.extend({}, CalendarRenderer.prototype.custom_events, { + archive_event: '_onArchiveEvent', + }), + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * Adds the Sync with Outlook button in the sidebar + * + * @private + */ + _initSidebar: function () { + var self = this; + this._super.apply(this, arguments); + this.$microsoftButton = $(); + if (this.model === "calendar.event") { + if (this.state.microsoft_is_sync) { + this.$microsoftButton = $('<span/>', {html: _t("Synched with Outlook")}) + .addClass('o_microsoft_sync badge badge-pill badge-success') + .prepend($('<i/>', {class: "fa mr-2 fa-check"})) + .appendTo(self.$sidebar); + } else { + this.$microsoftButton = $('<button/>', {type: 'button', html: _t("Sync with <b>Outlook</b>")}) + .addClass('o_microsoft_sync_button oe_button btn btn-secondary') + .appendTo(self.$sidebar); + } + } + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Requests to sync the calendar with Microsoft Calendar + * + * @private + */ + _onSyncMicrosoftCalendar: function () { + var self = this; + var context = this.getSession().user_context; + this.$microsoftButton.prop('disabled', true); + this.trigger_up('syncMicrosoftCalendar', { + on_always: function () { + self.$microsoftButton.prop('disabled', false); + }, + }); + }, + + _onArchiveEvent: function (ev) { + this._unselectEvent(); + this.trigger_up('archiveRecord', {id: parseInt(ev.data.id, 10)}); + }, +}); + +return { + MicrosoftCalendarController, + MicrosoftCalendarModel, + MicrosoftCalendarRenderer, +}; + +}); diff --git a/addons/microsoft_calendar/static/src/js/microsoft_calendar_popover.js b/addons/microsoft_calendar/static/src/js/microsoft_calendar_popover.js new file mode 100644 index 00000000..2699e0b3 --- /dev/null +++ b/addons/microsoft_calendar/static/src/js/microsoft_calendar_popover.js @@ -0,0 +1,34 @@ +odoo.define('microsoft_calendar.MicrosoftCalendarPopover', function(require) { + "use strict"; + + const CalendarPopover = require('web.CalendarPopover'); + + const MicrosoftCalendarPopover = CalendarPopover.include({ + events: _.extend({}, CalendarPopover.prototype.events, { + 'click .o_cw_popover_archive_m': '_onClickPopoverArchive', + }), + + /** + * We only want one 'Archive' button in the popover + * so if Google Sync is also active, it takes precedence + * over this popvoer. + */ + isMEventSyncedAndArchivable() { + if (this.event.extendedProps.record.google_id === undefined) { + return this.event.extendedProps.record.microsoft_id; + } + return !this.event.extendedProps.record.google_id && this.event.extendedProps.record.microsoft_id + }, + + isEventDeletable() { + return !this.isMEventSyncedAndArchivable() && this._super(); + }, + + _onClickPopoverArchive: function (ev) { + ev.preventDefault(); + this.trigger_up('archive_event', {id: this.event.id}); + }, + }); + + return MicrosoftCalendarPopover; +}); diff --git a/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss b/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss new file mode 100644 index 00000000..2f1fa96b --- /dev/null +++ b/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss @@ -0,0 +1,14 @@ +.o_microsoft_sync_button { + margin: auto; + > img { + margin-right: 10px; + } +} +.o_microsoft_sync.badge { + border: none; +} + +img.calendar_img_tuto { + margin: 0 0 10px 50px; + border: 2px solid $o-brand-secondary; +} diff --git a/addons/microsoft_calendar/static/src/xml/microsoft_calendar_popover.xml b/addons/microsoft_calendar/static/src/xml/microsoft_calendar_popover.xml new file mode 100644 index 00000000..aace2731 --- /dev/null +++ b/addons/microsoft_calendar/static/src/xml/microsoft_calendar_popover.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates> + <t t-extend="Calendar.attendee.status.popover"> + <t t-jquery=".o_cw_popover_edit" t-operation="after"> + <a t-if="typeof widget.isMEventSyncedAndArchivable === 'function' and widget.isMEventSyncedAndArchivable() and widget.isEventDetailsVisible()" href="#" class="btn btn-secondary o_cw_popover_archive_m">Archive</a> + </t> + </t> +</templates> |
