diff --git a/assets/app.js b/assets/app.js index 08362c34481017ba55c16cff2f22fb5b56c5db7d..4ccccc33f9a9acce05fb6c873e237e42bf8e4fd6 100644 --- a/assets/app.js +++ b/assets/app.js @@ -4,12 +4,8 @@ * We recommend including the built version of this JavaScript file * (and its CSS file) in your base layout (base.html.twig). */ - -// any CSS you import will output into a single css file (app.css in this case) -import './styles/app.css'; - // start the Stimulus application -import './bootstrap'; +//import './bootstrap'; import 'tui-calendar'; import 'bootstrap'; diff --git a/assets/calendar.js b/assets/calendar.js index c1d43fcce1accb639533e33d254b530b28ae7f45..9a1743b48e08c47cb907edeaf81e76840a748636 100644 --- a/assets/calendar.js +++ b/assets/calendar.js @@ -6,49 +6,99 @@ */ // any CSS you import will output into a single css file (app.css in this case) -import './styles/app.css'; // start the Stimulus application -import './bootstrap'; +//import './bootstrap'; import 'tui-calendar'; var Calendar = require('tui-calendar'); /* CommonJS */ -require("tui-calendar/dist/tui-calendar.css"); -// If you use the default popups, use this. -require("tui-date-picker/dist/tui-date-picker.css"); -require("tui-time-picker/dist/tui-time-picker.css"); +//console.log(calendar) -var calendar = new Calendar('#calendar', { - defaultView: 'week', - taskView: true, -}); -prevBtn.addEventListener("click", e => { - calendar.prev(); -}); -nextBtn.addEventListener("click", e => { - calendar.next(); -}); -calendar.createSchedules([ +$(document).ready(function () { + var calendar = new Calendar('#calendar', { + defaultView: 'week', + taskView: false, + useCreationPopup: true, + useDetailPopup: true + }); + + var scheduleIds = [] + var currentSchedule = 1 + + function sendCalendarData() { + calendar.getSchedule() + scheduleIds.forEach(function(id){ + var schedule = calendar.getSchedule(id, '1'); + console.log(schedule) + }) + + $.ajax({ + type: "POST", + url: "/calendar/send", + data: calendar._controller.schedules.items, + success: function (data) { console.log(data) }, + dataType: "application/json" + }); + } + + calendar.on('beforeCreateSchedule', function (event) { + var scheduleData = event + // var calendarId = '1'; + var schedule = { + id: String(currentSchedule), + calendarId: '1', + title: scheduleData.title, + isAllDay: scheduleData.isAllDay, + start: scheduleData.start, + end: scheduleData.end, + category: scheduleData.isAllDay ? 'allday' : 'time', + dueDateClass: '', + color: calendar.color, + bgColor: calendar.bgColor, + dragBgColor: calendar.bgColor, + borderColor: calendar.borderColor, + location: scheduleData.location, + isPrivate: scheduleData.isPrivate, + state: scheduleData.state + }; + + scheduleIds[scheduleIds.length] = currentSchedule; + currentSchedule++; + + sendCalendarData(); + + calendar.createSchedules([schedule]); + }); + + prevBtn.addEventListener("click", e => { + calendar.prev(); + }); + nextBtn.addEventListener("click", e => { + calendar.next(); + sendCalendarData(); + }); + calendar.createSchedules([ { - id: '1', - calendarId: '1', - title: 'my schedule', - category: 'time', - dueDateClass: '', - start: '2022-02-10T22:30:00+09:00', - end: '2022-02-11T02:30:00+09:00' + id: '1', + calendarId: '1', + title: 'my schedule', + category: 'time', + dueDateClass: '', + start: '2022-02-10T22:30:00+09:00', + end: '2022-02-11T02:30:00+09:00' }, { - id: '2', - calendarId: '1', - title: 'second schedule', - category: 'time', - dueDateClass: '', - start: '2022-02-11T17:30:00+09:00', - end: '2022-02-12T17:31:00+09:00', - isReadOnly: true // schedule is read-only + id: '2', + calendarId: '1', + title: 'second schedule', + category: 'time', + dueDateClass: '', + start: '2022-02-11T17:30:00+09:00', + end: '2022-02-12T17:31:00+09:00', + isReadOnly: true // schedule is read-only } -]); + ]); +}); diff --git a/assets/styles/app.css b/assets/styles/app.css deleted file mode 100644 index cb33b131595765db651e2be3d47e211f6c8fd0ee..0000000000000000000000000000000000000000 --- a/assets/styles/app.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background-color: lightgray; -} diff --git a/assets/styles/app.scss b/assets/styles/app.scss new file mode 100644 index 0000000000000000000000000000000000000000..ef484a7abd50eebfbc56b0019916b9558e1cb499 --- /dev/null +++ b/assets/styles/app.scss @@ -0,0 +1,8 @@ +@import '~bootstrap/scss/bootstrap'; +@import "~tui-calendar/dist/tui-calendar.css"; +@import "~tui-date-picker/dist/tui-date-picker.css"; +@import "~tui-time-picker/dist/tui-time-picker.css"; + +body { + background-color: lightgray; +} diff --git a/package.json b/package.json index 7575d1b421eac97722e206d06a74a04b6d88a751..5537eaf1fe66190e998e6fd668bbee4f553b26b9 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "@symfony/webpack-encore": "^1.7.0", "core-js": "^3.0.0", "regenerator-runtime": "^0.13.2", + "sass": "^1.49.7", + "sass-loader": "^12.0.0", "webpack-notifier": "^1.6.0" }, "license": "UNLICENSED", @@ -16,7 +18,9 @@ "build": "encore production --progress" }, "dependencies": { + "@popperjs/core": "^2.11.2", "bootstrap": "^5.1.3", + "jquery": "^3.6.0", "tui-calendar": "^1.15.2" } } diff --git a/templates/base.html.twig b/templates/base.html.twig index d4f83f7f8bf0387ab3873e312961337fa3589b85..ee61e9a638012f271cde29fe9f1266b6987d07e2 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -8,12 +8,12 @@ {% block stylesheets %} {{ encore_entry_link_tags('app') }} {% endblock %} - - {% block javascripts %} - {{ encore_entry_script_tags('app') }} - {% endblock %} </head> <body> {% block body %}{% endblock %} </body> + + {% block javascripts %} + {{ encore_entry_script_tags('app') }} + {% endblock %} </html> diff --git a/templates/calendar/index.html.twig b/templates/calendar/index.html.twig index de3a6ab57f95abc589805b34fb966d7f9792b363..890d2eb7d5d90c485e633d6e17225acca4e8798d 100644 --- a/templates/calendar/index.html.twig +++ b/templates/calendar/index.html.twig @@ -1,32 +1,61 @@ {% extends 'base.html.twig' %} -{% block title %}Hello CalendarController!{% endblock %} +{% block title %}Hello CalendarController! +{% endblock %} {% block javascripts %} -{{ parent() }} -{{ encore_entry_script_tags('calendar') }} + {{ parent() }} + {{ encore_entry_script_tags('calendar') }} {% endblock %} {% block body %} -<style> - .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; } - .example-wrapper code { background: #F5F5F5; padding: 2px 6px; } -</style> + <style> + .example-wrapper { + margin: 1em auto; + max-width: 800px; + width: 95%; + font: 18px / 1.5 sans-serif; + } + .example-wrapper code { + background: #F5F5F5; + padding: 2px 6px; + } + </style> -<div class="example-wrapper"> - <h1>Hello {{ controller_name }}! ✅</h1> + <div class="example-wrapper"> + <h1>Hello + {{ controller_name }}! ✅</h1> - This friendly message is coming from: - <ul> - <li>Your controller at <code><a href="{{ '/home/fanevark/step/calendrier/src/Controller/CalendarController.php'|file_link(0) }}">src/Controller/CalendarController.php</a></code></li> - <li>Your template at <code><a href="{{ '/home/fanevark/step/calendrier/templates/calendar/index.html.twig'|file_link(0) }}">templates/calendar/index.html.twig</a></code></li> - </ul> -</div> + This friendly message is coming from: + <ul> + <li>Your controller at + <code> + <a href="{{ '/home/fanevark/step/calendrier/src/Controller/CalendarController.php'|file_link(0) }}">src/Controller/CalendarController.php</a> + </code> + </li> + <li>Your template at + <code> + <a href="{{ '/home/fanevark/step/calendrier/templates/calendar/index.html.twig'|file_link(0) }}">templates/calendar/index.html.twig</a> + </code> + </li> + </ul> + </div> -<body> - <div id="calendar" style"height: 800px;"></div> - <button id="prevBtn">Prev</button> - <button id="nextBtn">Next</button> -</body> + <body> + <div class="card"> + <div class="card-header"> + Feedback de la journée + </div> + <div class="card-body"> + Est ce que vous avez respectez vos engagements ? + <button class="btn btn-success">Oui</button> + <button class="btn btn-danger">Non</button> + </div> + </div> + {# <div id="calendar" style"height: 800px;"></div> #} + <button id="prevBtn" class="btn btn-secondary">Prev</button> + <button id="nextBtn" class="btn btn-primary">Next</button> + <div id="calendarList"></div> + </body> {% endblock %} diff --git a/webpack.config.js b/webpack.config.js index cd84968761b162a7b2237e653bd0ddfef8c85b75..f5f66ce11db00bced7bb807eac7f995bf91aeea6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -20,11 +20,11 @@ Encore * Each entry will result in one JavaScript file (e.g. app.js) * and one CSS file (e.g. app.css) if your JavaScript imports CSS. */ - .addEntry('app', './assets/app.js') - .addEntry('calendar', './assets/calendar.js') + .addEntry('app', ['./assets/app.js','./assets/styles/app.scss']) + .addEntry('calendar', ['./assets/calendar.js','./assets/styles/app.scss']) // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js) - .enableStimulusBridge('./assets/controllers.json') + //.enableStimulusBridge('./assets/controllers.json') // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. .splitEntryChunks() @@ -57,7 +57,7 @@ Encore }) // enables Sass/SCSS support - //.enableSassLoader() + .enableSassLoader() // uncomment if you use TypeScript //.enableTypeScriptLoader() @@ -70,7 +70,7 @@ Encore //.enableIntegrityHashes(Encore.isProduction()) // uncomment if you're having problems with a jQuery plugin - //.autoProvidejQuery() + .autoProvidejQuery() ; module.exports = Encore.getWebpackConfig(); diff --git a/yarn.lock b/yarn.lock index f999f8dfc074cc8e892c770166a10664cd1b339c..435cc95f9505ea6f9bebbe68afc66314c760ec2e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -959,6 +959,11 @@ error-stack-parser "^2.0.0" string-width "^4.2.3" +"@popperjs/core@^2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.2.tgz#830beaec4b4091a9e9398ac50f865ddea52186b9" + integrity sha512-92FRmppjjqz29VMJ2dn+xdyXZBrMlE42AV6Kq6BwjWV7CNUW1hs2FtxSNLQE+gJhaZ6AAmYuO9y8dshhcBl7vA== + "@symfony/stimulus-bridge@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@symfony/stimulus-bridge/-/stimulus-bridge-3.0.0.tgz#9976ab27fb41c80111ffdcc43c17c49b75521b02" @@ -1708,7 +1713,7 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chokidar@^3.5.3: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -2769,6 +2774,11 @@ ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== +immutable@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23" + integrity sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw== + import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -2965,6 +2975,11 @@ jest-worker@^27.4.5: merge-stream "^2.0.0" supports-color "^8.0.0" +jquery@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470" + integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw== + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3014,6 +3029,11 @@ kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klona@^2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.5.tgz#d166574d90076395d9963aa7a928fabb8d76afbc" + integrity sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ== + lilconfig@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" @@ -4047,6 +4067,23 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +sass-loader@^12.0.0: + version "12.4.0" + resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-12.4.0.tgz#260b0d51a8a373bb8e88efc11f6ba5583fea0bcf" + integrity sha512-7xN+8khDIzym1oL9XyS6zP6Ges+Bo2B2xbPrjdMHEYyV3AQYhd/wXeru++3ODHF0zMjYmVadblSKrPrjEkL8mg== + dependencies: + klona "^2.0.4" + neo-async "^2.6.2" + +sass@^1.49.7: + version "1.49.7" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.49.7.tgz#22a86a50552b9b11f71404dfad1b9ff44c6b0c49" + integrity sha512-13dml55EMIR2rS4d/RDHHP0sXMY3+30e1TKsyXaSz3iLWVoDWEoboY8WzJd5JMnxrRHffKO3wq2mpJ0jxRJiEQ== + dependencies: + chokidar ">=3.0.0 <4.0.0" + immutable "^4.0.0" + source-map-js ">=0.6.2 <2.0.0" + schema-utils@^2.6.5: version "2.7.1" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7" @@ -4218,7 +4255,7 @@ source-list-map@^2.0.0: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== -source-map-js@^1.0.2: +"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==