From e0d9d3a6b9d25b70452648bf7669f26647539278 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Sun, 11 Aug 2024 14:18:36 +0200 Subject: [PATCH] Calendar is fullscreen --- .idea/dataSources.local.xml | 2 +- .idea/workspace.xml | 88 +++++++++++++++---- Gemfile | 4 - app/assets/config/manifest.js | 2 +- app/assets/javascripts/application.js | 1 - .../javascripts/toastui-calendar.min.js | 9 -- .../stylesheets/application.tailwind.css | 8 ++ .../stylesheets/reservations.tailwind.css | 0 .../stylesheets/toastui-calendar.min.css | 6 -- app/controllers/places_controller.rb | 72 --------------- app/controllers/reservations_controller.rb | 7 ++ app/controllers/teams_controller.rb | 70 +++++++++++++++ app/helpers/places_helper.rb | 2 - app/helpers/teams_helper.rb | 2 + app/javascript/application.js | 1 - app/javascript/controllers/application.js | 1 + .../controllers/hello_controller.js | 7 -- .../controllers/main_calendar_controller.js | 26 ++++++ app/models/company.rb | 2 +- app/models/place.rb | 3 - app/models/team.rb | 2 + app/views/layouts/application.html.erb | 6 +- app/views/layouts/calendar.html.erb | 21 +++++ app/views/places/_form.html.erb | 22 ----- app/views/places/_place.html.erb | 12 --- app/views/places/_place.json.jbuilder | 2 - app/views/places/edit.html.erb | 8 -- app/views/places/index.html.erb | 21 ----- app/views/places/index.json.jbuilder | 1 - app/views/places/new.html.erb | 7 -- app/views/places/show.html.erb | 15 ---- app/views/places/show.json.jbuilder | 1 - app/views/reservations/_form.html.erb | 4 +- app/views/reservations/index.html.erb | 12 +-- app/views/teams/_form.html.erb | 17 ++++ app/views/teams/_team.html.erb | 2 + app/views/teams/_team.json.jbuilder | 2 + app/views/teams/edit.html.erb | 8 ++ app/views/teams/index.html.erb | 21 +++++ app/views/teams/index.json.jbuilder | 1 + app/views/teams/new.html.erb | 7 ++ app/views/teams/show.html.erb | 15 ++++ app/views/teams/show.json.jbuilder | 1 + config/importmap.rb | 3 +- .../initializers/content_security_policy.rb | 34 +++---- config/routes.rb | 2 +- db/migrate/20240804060103_create_places.rb | 10 --- ...title_and_description_from_reservations.rb | 6 ++ db/migrate/20240810054948_create_teams.rb | 8 ++ db/schema.rb | 9 +- test/controllers/places_controller_test.rb | 48 ---------- test/controllers/teams_controller_test.rb | 48 ++++++++++ test/fixtures/places.yml | 9 -- test/fixtures/teams.yml | 11 +++ test/models/{place_test.rb => team_test.rb} | 2 +- test/system/places_test.rb | 43 --------- test/system/teams_test.rb | 39 ++++++++ 57 files changed, 431 insertions(+), 362 deletions(-) delete mode 100644 app/assets/javascripts/application.js delete mode 100644 app/assets/javascripts/toastui-calendar.min.js create mode 100644 app/assets/stylesheets/reservations.tailwind.css delete mode 100644 app/assets/stylesheets/toastui-calendar.min.css delete mode 100644 app/controllers/places_controller.rb create mode 100644 app/controllers/teams_controller.rb delete mode 100644 app/helpers/places_helper.rb create mode 100644 app/helpers/teams_helper.rb delete mode 100644 app/javascript/controllers/hello_controller.js create mode 100644 app/javascript/controllers/main_calendar_controller.js delete mode 100644 app/models/place.rb create mode 100644 app/models/team.rb create mode 100644 app/views/layouts/calendar.html.erb delete mode 100644 app/views/places/_form.html.erb delete mode 100644 app/views/places/_place.html.erb delete mode 100644 app/views/places/_place.json.jbuilder delete mode 100644 app/views/places/edit.html.erb delete mode 100644 app/views/places/index.html.erb delete mode 100644 app/views/places/index.json.jbuilder delete mode 100644 app/views/places/new.html.erb delete mode 100644 app/views/places/show.html.erb delete mode 100644 app/views/places/show.json.jbuilder create mode 100644 app/views/teams/_form.html.erb create mode 100644 app/views/teams/_team.html.erb create mode 100644 app/views/teams/_team.json.jbuilder create mode 100644 app/views/teams/edit.html.erb create mode 100644 app/views/teams/index.html.erb create mode 100644 app/views/teams/index.json.jbuilder create mode 100644 app/views/teams/new.html.erb create mode 100644 app/views/teams/show.html.erb create mode 100644 app/views/teams/show.json.jbuilder delete mode 100644 db/migrate/20240804060103_create_places.rb create mode 100644 db/migrate/20240810044255_remove_title_and_description_from_reservations.rb create mode 100644 db/migrate/20240810054948_create_teams.rb delete mode 100644 test/controllers/places_controller_test.rb create mode 100644 test/controllers/teams_controller_test.rb delete mode 100644 test/fixtures/places.yml create mode 100644 test/fixtures/teams.yml rename test/models/{place_test.rb => team_test.rb} (64%) delete mode 100644 test/system/places_test.rb create mode 100644 test/system/teams_test.rb diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index a27de0f..aef3108 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -1,6 +1,6 @@ - + no-auth diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 10e5a25..bf84577 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,17 +5,57 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -30,32 +70,41 @@ "associatedIndex": 7 } + + + - { - "keyToString": { - "ASKED_ADD_EXTERNAL_FILES": "true", - "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", - "Rails.terminator.executor": "Run", - "RunOnceActivity.ShowReadmeOnStart": "true", - "last_opened_file_path": "/home/hamo/projects/kbr4/terminator/app/assets/stylesheets", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "ruby.structure.view.model.defaults.configured": "true", - "settings.editor.selected.configurable": "org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable", - "vue.rearranger.settings.migration": "true" + +}]]> + + + + + @@ -137,7 +186,7 @@ - @@ -159,7 +208,8 @@ - + + diff --git a/Gemfile b/Gemfile index d4bb5fa..610affc 100644 --- a/Gemfile +++ b/Gemfile @@ -44,10 +44,6 @@ gem "tzinfo-data", platforms: %i[ windows jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false - -gem 'stimulus-rails' -gem "hotwire_combobox" - # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index b06fc42..cd04671 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,4 +2,4 @@ //= link_directory ../stylesheets .css //= link_tree ../../javascript .js //= link_tree ../../../vendor/javascript .js -//= link_tree ../builds +//= link_tree ../builds \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index 9719653..0000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1 +0,0 @@ -//require 'toastui-calendar.min.js' \ No newline at end of file diff --git a/app/assets/javascripts/toastui-calendar.min.js b/app/assets/javascripts/toastui-calendar.min.js deleted file mode 100644 index d3554d5..0000000 --- a/app/assets/javascripts/toastui-calendar.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * TOAST UI Calendar 2nd Edition - * @version 2.1.3 | Tue Aug 16 2022 - * @author NHN Cloud FE Development Lab - * @license MIT - */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("tui-date-picker")):"function"==typeof define&&define.amd?define(["tui-date-picker"],t):"object"==typeof exports?exports.tui=t(require("tui-date-picker")):(e.tui=e.tui||{},e.tui.Calendar=t(e.tui.DatePicker))}(this,(function(e){return function(){var t={7111:function(e,t,n){var r=n(6733),o=n(9821),i=TypeError;e.exports=function(e){if(r(e))return e;throw i(o(e)+" is not a function")}},8505:function(e,t,n){var r=n(6733),o=String,i=TypeError;e.exports=function(e){if("object"==typeof e||r(e))return e;throw i("Can't set "+o(e)+" as a prototype")}},9736:function(e,t,n){var r=n(95),o=n(2391),i=n(1787).f,a=r("unscopables"),l=Array.prototype;null==l[a]&&i(l,a,{configurable:!0,value:o(null)}),e.exports=function(e){l[a][e]=!0}},6637:function(e,t,n){"use strict";var r=n(966).charAt;e.exports=function(e,t,n){return t+(n?r(e,t).length:1)}},1176:function(e,t,n){var r=n(5052),o=String,i=TypeError;e.exports=function(e){if(r(e))return e;throw i(o(e)+" is not an object")}},9540:function(e,t,n){var r=n(905),o=n(3231),i=n(9646),a=function(e){return function(t,n,a){var l,c=r(t),s=i(c),u=o(a,s);if(e&&n!=n){for(;s>u;)if((l=c[u++])!=l)return!0}else for(;s>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},7079:function(e,t,n){var r=n(5968),o=r({}.toString),i=r("".slice);e.exports=function(e){return i(o(e),8,-1)}},1589:function(e,t,n){var r=n(1601),o=n(6733),i=n(7079),a=n(95)("toStringTag"),l=Object,c="Arguments"==i(function(){return arguments}());e.exports=r?i:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=l(e),a))?n:c?i(t):"Object"==(r=i(t))&&o(t.callee)?"Arguments":r}},1590:function(e,t,n){var r=n(5968),o=Error,i=r("".replace),a=String(o("zxcasd").stack),l=/\n\s*at [^:]*:[^\n]*/,c=l.test(a);e.exports=function(e,t){if(c&&"string"==typeof e&&!o.prepareStackTrace)for(;t--;)e=i(e,l,"");return e}},7081:function(e,t,n){var r=n(8270),o=n(4826),i=n(7933),a=n(1787);e.exports=function(e,t,n){for(var l=o(t),c=a.f,s=i.f,u=0;u0&&r[0]<4?1:+(r[0]+r[1])),!o&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(o=+r[1]),e.exports=o},3837:function(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},373:function(e,t,n){var r=n(4229),o=n(5358);e.exports=!r((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",o(1,7)),7!==e.stack)}))},3103:function(e,t,n){var r=n(9859),o=n(7933).f,i=n(5762),a=n(4768),l=n(8400),c=n(7081),s=n(6541);e.exports=function(e,t){var n,u,d,f,p,h=e.target,m=e.global,g=e.stat;if(n=m?r:g?r[h]||l(h,{}):(r[h]||{}).prototype)for(u in t){if(f=t[u],d=e.dontCallGetSet?(p=o(n,u))&&p.value:n[u],!s(m?u:h+(g?".":"#")+u,e.forced)&&void 0!==d){if(typeof f==typeof d)continue;c(f,d)}(e.sham||d&&d.sham)&&i(f,"sham",!0),a(n,u,f,e)}}},4229:function(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},4954:function(e,t,n){"use strict";n(7950);var r=n(5968),o=n(4768),i=n(3466),a=n(4229),l=n(95),c=n(5762),s=l("species"),u=RegExp.prototype;e.exports=function(e,t,n,d){var f=l(e),p=!a((function(){var t={};return t[f]=function(){return 7},7!=""[e](t)})),h=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[s]=function(){return n},n.flags="",n[f]=/./[f]),n.exec=function(){return t=!0,null},n[f](""),!t}));if(!p||!h||n){var m=r(/./[f]),g=t(f,""[e],(function(e,t,n,o,a){var l=r(e),c=t.exec;return c===i||c===u.exec?p&&!a?{done:!0,value:m(t,n,o)}:{done:!0,value:l(n,t,o)}:{done:!1}}));o(String.prototype,e,g[0]),o(u,f,g[1])}d&&c(u[f],"sham",!0)}},3171:function(e,t,n){var r=n(7188),o=Function.prototype,i=o.apply,a=o.call;e.exports="object"==typeof Reflect&&Reflect.apply||(r?a.bind(i):function(){return a.apply(i,arguments)})},7188:function(e,t,n){var r=n(4229);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},266:function(e,t,n){var r=n(7188),o=Function.prototype.call;e.exports=r?o.bind(o):function(){return o.apply(o,arguments)}},1805:function(e,t,n){var r=n(7400),o=n(8270),i=Function.prototype,a=r&&Object.getOwnPropertyDescriptor,l=o(i,"name"),c=l&&"something"===function(){}.name,s=l&&(!r||r&&a(i,"name").configurable);e.exports={EXISTS:l,PROPER:c,CONFIGURABLE:s}},5968:function(e,t,n){var r=n(7188),o=Function.prototype,i=o.bind,a=o.call,l=r&&i.bind(a,a);e.exports=r?function(e){return e&&l(e)}:function(e){return e&&function(){return a.apply(e,arguments)}}},1333:function(e,t,n){var r=n(9859),o=n(6733),i=function(e){return o(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?i(r[e]):r[e]&&r[e][t]}},5300:function(e,t,n){var r=n(7111);e.exports=function(e,t){var n=e[t];return null==n?void 0:r(n)}},17:function(e,t,n){var r=n(5968),o=n(2991),i=Math.floor,a=r("".charAt),l=r("".replace),c=r("".slice),s=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,n,r,d,f){var p=n+e.length,h=r.length,m=u;return void 0!==d&&(d=o(d),m=s),l(f,m,(function(o,l){var s;switch(a(l,0)){case"$":return"$";case"&":return e;case"`":return c(t,0,n);case"'":return c(t,p);case"<":s=d[c(l,1,-1)];break;default:var u=+l;if(0===u)return o;if(u>h){var f=i(u/10);return 0===f?o:f<=h?void 0===r[f-1]?a(l,1):r[f-1]+a(l,1):o}s=r[u-1]}return void 0===s?"":s}))}},9859:function(e,t,n){var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},8270:function(e,t,n){var r=n(5968),o=n(2991),i=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(o(e),t)}},5977:function(e){e.exports={}},3777:function(e,t,n){var r=n(1333);e.exports=r("document","documentElement")},4394:function(e,t,n){var r=n(7400),o=n(4229),i=n(2635);e.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},9337:function(e,t,n){var r=n(5968),o=n(4229),i=n(7079),a=Object,l=r("".split);e.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==i(e)?l(e,""):a(e)}:a},835:function(e,t,n){var r=n(6733),o=n(5052),i=n(6540);e.exports=function(e,t,n){var a,l;return i&&r(a=t.constructor)&&a!==n&&o(l=a.prototype)&&l!==n.prototype&&i(e,l),e}},8511:function(e,t,n){var r=n(5968),o=n(6733),i=n(5353),a=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},9679:function(e,t,n){var r=n(5052),o=n(5762);e.exports=function(e,t){r(t)&&"cause"in t&&o(e,"cause",t.cause)}},6407:function(e,t,n){var r,o,i,a=n(8694),l=n(9859),c=n(5968),s=n(5052),u=n(5762),d=n(8270),f=n(5353),p=n(4399),h=n(5977),m="Object already initialized",g=l.TypeError,v=l.WeakMap;if(a||f.state){var y=f.state||(f.state=new v),w=c(y.get),_=c(y.has),b=c(y.set);r=function(e,t){if(_(y,e))throw new g(m);return t.facade=e,b(y,e,t),t},o=function(e){return w(y,e)||{}},i=function(e){return _(y,e)}}else{var x=p("state");h[x]=!0,r=function(e,t){if(d(e,x))throw new g(m);return t.facade=e,u(e,x,t),t},o=function(e){return d(e,x)?e[x]:{}},i=function(e){return d(e,x)}}e.exports={set:r,get:o,has:i,enforce:function(e){return i(e)?o(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!s(t)||(n=o(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return n}}}},6733:function(e){e.exports=function(e){return"function"==typeof e}},6541:function(e,t,n){var r=n(4229),o=n(6733),i=/#|\.prototype\./,a=function(e,t){var n=c[l(e)];return n==u||n!=s&&(o(t)?r(t):!!t)},l=a.normalize=function(e){return String(e).replace(i,".").toLowerCase()},c=a.data={},s=a.NATIVE="N",u=a.POLYFILL="P";e.exports=a},5052:function(e,t,n){var r=n(6733);e.exports=function(e){return"object"==typeof e?null!==e:r(e)}},4231:function(e){e.exports=!1},9395:function(e,t,n){var r=n(1333),o=n(6733),i=n(1321),a=n(6969),l=Object;e.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=r("Symbol");return o(t)&&i(t.prototype,l(e))}},693:function(e,t,n){"use strict";var r,o,i,a=n(4229),l=n(6733),c=n(2391),s=n(7567),u=n(4768),d=n(95),f=n(4231),p=d("iterator"),h=!1;[].keys&&("next"in(i=[].keys())?(o=s(s(i)))!==Object.prototype&&(r=o):h=!0),null==r||a((function(){var e={};return r[p].call(e)!==e}))?r={}:f&&(r=c(r)),l(r[p])||u(r,p,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:h}},5495:function(e){e.exports={}},9646:function(e,t,n){var r=n(4237);e.exports=function(e){return r(e.length)}},6039:function(e,t,n){var r=n(4229),o=n(6733),i=n(8270),a=n(7400),l=n(1805).CONFIGURABLE,c=n(8511),s=n(6407),u=s.enforce,d=s.get,f=Object.defineProperty,p=a&&!r((function(){return 8!==f((function(){}),"length",{value:8}).length})),h=String(String).split("String"),m=e.exports=function(e,t,n){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!i(e,"name")||l&&e.name!==t)&&(a?f(e,"name",{value:t,configurable:!0}):e.name=t),p&&n&&i(n,"arity")&&e.length!==n.arity&&f(e,"length",{value:n.arity});try{n&&i(n,"constructor")&&n.constructor?a&&f(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var r=u(e);return i(r,"source")||(r.source=h.join("string"==typeof t?t:"")),e};Function.prototype.toString=m((function(){return o(this)&&d(this).source||c(this)}),"toString")},917:function(e){var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function(e){var r=+e;return(r>0?n:t)(r)}},3839:function(e,t,n){var r=n(6358),o=n(4229);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},8694:function(e,t,n){var r=n(9859),o=n(6733),i=n(8511),a=r.WeakMap;e.exports=o(a)&&/native code/.test(i(a))},635:function(e,t,n){var r=n(3326);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:r(e)}},2391:function(e,t,n){var r,o=n(1176),i=n(219),a=n(3837),l=n(5977),c=n(3777),s=n(2635),u=n(4399),d=u("IE_PROTO"),f=function(){},p=function(e){return" <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> -
+
<%= yield %>
diff --git a/app/views/layouts/calendar.html.erb b/app/views/layouts/calendar.html.erb new file mode 100644 index 0000000..fc7f371 --- /dev/null +++ b/app/views/layouts/calendar.html.erb @@ -0,0 +1,21 @@ + + + + Terminator + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + + <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + + <%= javascript_importmap_tags %> + + + +
+ <%= yield %> +
+ + diff --git a/app/views/places/_form.html.erb b/app/views/places/_form.html.erb deleted file mode 100644 index f51e1c7..0000000 --- a/app/views/places/_form.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -<%= form_with(model: place, class: "contents") do |form| %> - <% if place.errors.any? %> -
-

<%= pluralize(place.errors.count, "error") %> prohibited this place from being saved:

- -
    - <% place.errors.each do |error| %> -
  • <%= error.full_message %>
  • - <% end %> -
-
- <% end %> - -
- <%= form.label :name %> - <%= form.text_field :name, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> -
- -
- <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> -
-<% end %> diff --git a/app/views/places/_place.html.erb b/app/views/places/_place.html.erb deleted file mode 100644 index 30aa3a9..0000000 --- a/app/views/places/_place.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -
-

- Name: - <%= place.name %> -

- -

- Company: - <%= place.company_id %> -

- -
diff --git a/app/views/places/_place.json.jbuilder b/app/views/places/_place.json.jbuilder deleted file mode 100644 index ff5cba9..0000000 --- a/app/views/places/_place.json.jbuilder +++ /dev/null @@ -1,2 +0,0 @@ -json.extract! place, :id, :name, :company_id, :created_at, :updated_at -json.url place_url(place, format: :json) diff --git a/app/views/places/edit.html.erb b/app/views/places/edit.html.erb deleted file mode 100644 index b0ff29d..0000000 --- a/app/views/places/edit.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -
-

Editing place

- - <%= render "form", place: @place %> - - <%= link_to "Show this place", @place, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
diff --git a/app/views/places/index.html.erb b/app/views/places/index.html.erb deleted file mode 100644 index 3dfe864..0000000 --- a/app/views/places/index.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> - - <% content_for :title, "Places" %> - -
-

Places

- <%= link_to "New place", new_place_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
- -
- <% @places.each do |place| %> - <%= render place %> -

- <%= link_to "Show this place", place, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -

- <% end %> -
-
diff --git a/app/views/places/index.json.jbuilder b/app/views/places/index.json.jbuilder deleted file mode 100644 index f1d6b30..0000000 --- a/app/views/places/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @places, partial: "places/place", as: :place diff --git a/app/views/places/new.html.erb b/app/views/places/new.html.erb deleted file mode 100644 index c7048cf..0000000 --- a/app/views/places/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
-

New place

- - <%= render "form", place: @place %> - - <%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
diff --git a/app/views/places/show.html.erb b/app/views/places/show.html.erb deleted file mode 100644 index 117e226..0000000 --- a/app/views/places/show.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -
-
- <% if notice.present? %> -

<%= notice %>

- <% end %> - - <%= render @place %> - - <%= link_to "Edit this place", edit_place_path(@place), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
- <%= button_to "Destroy this place", @place, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %> -
-
-
diff --git a/app/views/places/show.json.jbuilder b/app/views/places/show.json.jbuilder deleted file mode 100644 index e038dff..0000000 --- a/app/views/places/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! "places/place", place: @place diff --git a/app/views/reservations/_form.html.erb b/app/views/reservations/_form.html.erb index 0335a9c..02a8941 100644 --- a/app/views/reservations/_form.html.erb +++ b/app/views/reservations/_form.html.erb @@ -17,8 +17,8 @@
- <%= form.label :place_id %> - <%= form.collection_select :place_id, @company.places, :id, :name, prompt: "Select a Place", class:"block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> + <%= form.label :team_id %> + <%= form.collection_select :place_id, @company.teams, :id, :name, prompt: "Select a Team", class:"block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
diff --git a/app/views/reservations/index.html.erb b/app/views/reservations/index.html.erb index 9410147..5bda4cf 100644 --- a/app/views/reservations/index.html.erb +++ b/app/views/reservations/index.html.erb @@ -1,4 +1,4 @@ -
+
<% if notice.present? %>

<%= notice %>

<% end %> @@ -10,12 +10,8 @@ <%= link_to "New reservation", new_reservation_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
-
- <% @reservations.each do |reservation| %> - <%= render reservation %> -

- <%= link_to "Show this reservation", reservation, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -

- <% end %> +
+ +
diff --git a/app/views/teams/_form.html.erb b/app/views/teams/_form.html.erb new file mode 100644 index 0000000..9f26ef4 --- /dev/null +++ b/app/views/teams/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_with(model: team, class: "contents") do |form| %> + <% if team.errors.any? %> +
+

<%= pluralize(team.errors.count, "error") %> prohibited this team from being saved:

+ +
    + <% team.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> +
+<% end %> diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb new file mode 100644 index 0000000..086c2a2 --- /dev/null +++ b/app/views/teams/_team.html.erb @@ -0,0 +1,2 @@ +
+
diff --git a/app/views/teams/_team.json.jbuilder b/app/views/teams/_team.json.jbuilder new file mode 100644 index 0000000..ad324aa --- /dev/null +++ b/app/views/teams/_team.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! team, :id, :created_at, :updated_at +json.url team_url(team, format: :json) diff --git a/app/views/teams/edit.html.erb b/app/views/teams/edit.html.erb new file mode 100644 index 0000000..b28f46a --- /dev/null +++ b/app/views/teams/edit.html.erb @@ -0,0 +1,8 @@ +
+

Editing team

+ + <%= render "form", team: @team %> + + <%= link_to "Show this team", @team, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +
diff --git a/app/views/teams/index.html.erb b/app/views/teams/index.html.erb new file mode 100644 index 0000000..61bbffa --- /dev/null +++ b/app/views/teams/index.html.erb @@ -0,0 +1,21 @@ +
+ <% if notice.present? %> +

<%= notice %>

+ <% end %> + + <% content_for :title, "Teams" %> + +
+

Teams

+ <%= link_to "New team", new_team_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> +
+ +
+ <% @teams.each do |team| %> + <%= render team %> +

+ <%= link_to "Show this team", team, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +

+ <% end %> +
+
diff --git a/app/views/teams/index.json.jbuilder b/app/views/teams/index.json.jbuilder new file mode 100644 index 0000000..6d350e4 --- /dev/null +++ b/app/views/teams/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @teams, partial: "teams/team", as: :team diff --git a/app/views/teams/new.html.erb b/app/views/teams/new.html.erb new file mode 100644 index 0000000..de77350 --- /dev/null +++ b/app/views/teams/new.html.erb @@ -0,0 +1,7 @@ +
+

New team

+ + <%= render "form", team: @team %> + + <%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +
diff --git a/app/views/teams/show.html.erb b/app/views/teams/show.html.erb new file mode 100644 index 0000000..2f12a4f --- /dev/null +++ b/app/views/teams/show.html.erb @@ -0,0 +1,15 @@ +
+
+ <% if notice.present? %> +

<%= notice %>

+ <% end %> + + <%= render @team %> + + <%= link_to "Edit this team", edit_team_path(@team), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> + <%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> +
+ <%= button_to "Destroy this team", @team, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %> +
+
+
diff --git a/app/views/teams/show.json.jbuilder b/app/views/teams/show.json.jbuilder new file mode 100644 index 0000000..fee639b --- /dev/null +++ b/app/views/teams/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "teams/team", team: @team diff --git a/config/importmap.rb b/config/importmap.rb index 909dfc5..0ea2e3b 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,7 +1,6 @@ # Pin npm packages by running ./bin/importmap -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js" pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" +pin "application" pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index b3076b3..dbfe0bf 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -5,21 +5,21 @@ # https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap, inline scripts, and inline styles. -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src style-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true +# config.content_security_policy do |policy| +# policy.default_src :self, :http, :unsafe_eval, :unsafe_inline +# policy.font_src :self, :http, :data +# policy.img_src :self, :http, :data +# policy.object_src :none +# policy.script_src :self, :unsafe_eval, :unsafe_inline +# policy.style_src :self, :http +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# # +# # # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# # config.content_security_policy_nonce_directives = %w(script-src style-src) +# # +# # # Report violations without enforcing the policy. +# # # config.content_security_policy_report_only = true # end diff --git a/config/routes.rb b/config/routes.rb index 073193e..8033ad0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Rails.application.routes.draw do + resources :teams resources :reservations - resources :places resources :customers resources :companies # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html diff --git a/db/migrate/20240804060103_create_places.rb b/db/migrate/20240804060103_create_places.rb deleted file mode 100644 index 2104f25..0000000 --- a/db/migrate/20240804060103_create_places.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreatePlaces < ActiveRecord::Migration[7.1] - def change - create_table :places do |t| - t.string :name - t.references :company, null: false, foreign_key: true - - t.timestamps - end - end -end diff --git a/db/migrate/20240810044255_remove_title_and_description_from_reservations.rb b/db/migrate/20240810044255_remove_title_and_description_from_reservations.rb new file mode 100644 index 0000000..8056503 --- /dev/null +++ b/db/migrate/20240810044255_remove_title_and_description_from_reservations.rb @@ -0,0 +1,6 @@ +class RemoveTitleAndDescriptionFromReservations < ActiveRecord::Migration[7.1] + def change + remove_column :reservations, :title, :string + remove_column :reservations, :description, :text + end +end diff --git a/db/migrate/20240810054948_create_teams.rb b/db/migrate/20240810054948_create_teams.rb new file mode 100644 index 0000000..fbbdd6d --- /dev/null +++ b/db/migrate/20240810054948_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration[7.1] + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4269b72..eff72c7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_08_04_060112) do +ActiveRecord::Schema[7.1].define(version: 2024_08_10_054948) do create_table "companies", force: :cascade do |t| t.string "name" t.string "id_number" @@ -48,8 +48,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_04_060112) do t.integer "company_id", null: false t.integer "customer_id", null: false t.integer "place_id", null: false - t.string "title" - t.text "description" t.datetime "start_time" t.datetime "end_time" t.datetime "created_at", null: false @@ -59,6 +57,11 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_04_060112) do t.index ["place_id"], name: "index_reservations_on_place_id" end + create_table "teams", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + add_foreign_key "places", "companies" add_foreign_key "reservations", "companies" add_foreign_key "reservations", "customers" diff --git a/test/controllers/places_controller_test.rb b/test/controllers/places_controller_test.rb deleted file mode 100644 index 1e8661b..0000000 --- a/test/controllers/places_controller_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "test_helper" - -class PlacesControllerTest < ActionDispatch::IntegrationTest - setup do - @place = places(:one) - end - - test "should get index" do - get places_url - assert_response :success - end - - test "should get new" do - get new_place_url - assert_response :success - end - - test "should create place" do - assert_difference("Place.count") do - post places_url, params: { place: { company_id: @place.company_id, name: @place.name } } - end - - assert_redirected_to place_url(Place.last) - end - - test "should show place" do - get place_url(@place) - assert_response :success - end - - test "should get edit" do - get edit_place_url(@place) - assert_response :success - end - - test "should update place" do - patch place_url(@place), params: { place: { company_id: @place.company_id, name: @place.name } } - assert_redirected_to place_url(@place) - end - - test "should destroy place" do - assert_difference("Place.count", -1) do - delete place_url(@place) - end - - assert_redirected_to places_url - end -end diff --git a/test/controllers/teams_controller_test.rb b/test/controllers/teams_controller_test.rb new file mode 100644 index 0000000..4aea2bd --- /dev/null +++ b/test/controllers/teams_controller_test.rb @@ -0,0 +1,48 @@ +require "test_helper" + +class TeamsControllerTest < ActionDispatch::IntegrationTest + setup do + @team = teams(:one) + end + + test "should get index" do + get teams_url + assert_response :success + end + + test "should get new" do + get new_team_url + assert_response :success + end + + test "should create team" do + assert_difference("Team.count") do + post teams_url, params: { team: { } } + end + + assert_redirected_to team_url(Team.last) + end + + test "should show team" do + get team_url(@team) + assert_response :success + end + + test "should get edit" do + get edit_team_url(@team) + assert_response :success + end + + test "should update team" do + patch team_url(@team), params: { team: { } } + assert_redirected_to team_url(@team) + end + + test "should destroy team" do + assert_difference("Team.count", -1) do + delete team_url(@team) + end + + assert_redirected_to teams_url + end +end diff --git a/test/fixtures/places.yml b/test/fixtures/places.yml deleted file mode 100644 index d01926e..0000000 --- a/test/fixtures/places.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - name: MyString - company: one - -two: - name: MyString - company: two diff --git a/test/fixtures/teams.yml b/test/fixtures/teams.yml new file mode 100644 index 0000000..d7a3329 --- /dev/null +++ b/test/fixtures/teams.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/place_test.rb b/test/models/team_test.rb similarity index 64% rename from test/models/place_test.rb rename to test/models/team_test.rb index 9f5cd09..c6cf23d 100644 --- a/test/models/place_test.rb +++ b/test/models/team_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class PlaceTest < ActiveSupport::TestCase +class TeamTest < ActiveSupport::TestCase # test "the truth" do # assert true # end diff --git a/test/system/places_test.rb b/test/system/places_test.rb deleted file mode 100644 index 813cce5..0000000 --- a/test/system/places_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require "application_system_test_case" - -class PlacesTest < ApplicationSystemTestCase - setup do - @place = places(:one) - end - - test "visiting the index" do - visit places_url - assert_selector "h1", text: "Places" - end - - test "should create place" do - visit places_url - click_on "New place" - - fill_in "Company", with: @place.company_id - fill_in "Name", with: @place.name - click_on "Create Place" - - assert_text "Place was successfully created" - click_on "Back" - end - - test "should update Place" do - visit place_url(@place) - click_on "Edit this place", match: :first - - fill_in "Company", with: @place.company_id - fill_in "Name", with: @place.name - click_on "Update Place" - - assert_text "Place was successfully updated" - click_on "Back" - end - - test "should destroy Place" do - visit place_url(@place) - click_on "Destroy this place", match: :first - - assert_text "Place was successfully destroyed" - end -end diff --git a/test/system/teams_test.rb b/test/system/teams_test.rb new file mode 100644 index 0000000..9df54b4 --- /dev/null +++ b/test/system/teams_test.rb @@ -0,0 +1,39 @@ +require "application_system_test_case" + +class TeamsTest < ApplicationSystemTestCase + setup do + @team = teams(:one) + end + + test "visiting the index" do + visit teams_url + assert_selector "h1", text: "Teams" + end + + test "should create team" do + visit teams_url + click_on "New team" + + click_on "Create Team" + + assert_text "Team was successfully created" + click_on "Back" + end + + test "should update Team" do + visit team_url(@team) + click_on "Edit this team", match: :first + + click_on "Update Team" + + assert_text "Team was successfully updated" + click_on "Back" + end + + test "should destroy Team" do + visit team_url(@team) + click_on "Destroy this team", match: :first + + assert_text "Team was successfully destroyed" + end +end