From 18603dc78364e021eca0113dcbd0fd96f6c16280 Mon Sep 17 00:00:00 2001 From: Dan Elbert Date: Thu, 6 Sep 2018 18:16:13 -0500 Subject: [PATCH] tasks --- app/controllers/task_items_controller.rb | 6 +- app/controllers/task_lists_controller.rb | 2 +- app/javascript/components/App.vue | 22 +- app/javascript/components/AppModal.vue | 8 +- app/javascript/components/TaskItemEdit.vue | 8 +- app/javascript/components/TaskItemList.vue | 75 +- app/javascript/components/TheTaskListList.vue | 55 +- app/javascript/components/UserLogin.vue | 35 +- app/javascript/lib/Api.js | 6 +- app/javascript/lib/GlobalMixins.js | 10 +- app/javascript/lib/VuexResponsiveSync.js | 44 + app/javascript/packs/application.js | 2 + app/javascript/store/index.js | 121 ++- app/models/concerns/default_values.rb | 95 ++ app/models/recipe.rb | 2 - app/models/task_item.rb | 3 + app/models/view_models/recipe_criteria.rb | 2 - app/views/home/sw.js.erb | 10 +- app/views/task_items/_task_item.json.jbuilder | 2 +- app/views/task_items/show.json.jbuilder | 1 + app/views/task_lists/_task_list.json.jbuilder | 2 +- config/routes.rb | 2 +- config/webpack/environment.js | 2 +- config/webpack/loaders/svg.js | 5 +- .../20180906191333_update_task_items.rb | 13 + db/schema.rb | 3 +- lib/tasks/dev.rake | 25 + package.json | 1 + yarn.lock | 872 +++++++++--------- 29 files changed, 873 insertions(+), 561 deletions(-) create mode 100644 app/javascript/lib/VuexResponsiveSync.js create mode 100644 app/models/concerns/default_values.rb create mode 100644 app/views/task_items/show.json.jbuilder create mode 100644 db/migrate/20180906191333_update_task_items.rb create mode 100644 lib/tasks/dev.rake diff --git a/app/controllers/task_items_controller.rb b/app/controllers/task_items_controller.rb index 9147ead..10b71b2 100644 --- a/app/controllers/task_items_controller.rb +++ b/app/controllers/task_items_controller.rb @@ -9,7 +9,7 @@ class TaskItemsController < ApplicationController @task_item.task_list = @task_list if @task_item.save - render :show, status: :created, location: @task_item + render :show, status: :created, location: [@task_list, @task_item] else render json: @task_item.errors, status: :unprocessable_entity end @@ -17,7 +17,7 @@ class TaskItemsController < ApplicationController def update if @task_item.update(task_item_params) - render :show, status: :ok, location: @task_item + render :show, status: :ok, location: [@task_list, @task_item] else render json: @task_item.errors, status: :unprocessable_entity end @@ -31,7 +31,7 @@ class TaskItemsController < ApplicationController private def task_item_params - params.require(:task_item).permit(:name, :quantity) + params.require(:task_item).permit(:name, :quantity, :completed) end def set_task_list diff --git a/app/controllers/task_lists_controller.rb b/app/controllers/task_lists_controller.rb index 54086dd..99254fe 100644 --- a/app/controllers/task_lists_controller.rb +++ b/app/controllers/task_lists_controller.rb @@ -4,7 +4,7 @@ class TaskListsController < ApplicationController before_action :set_task_list, only: [:show, :update, :destroy] def index - @task_lists = TaskList.for_user(current_user).order(created_at: :desc) + @task_lists = TaskList.for_user(current_user).includes(:task_items).order(created_at: :desc) end def show diff --git a/app/javascript/components/App.vue b/app/javascript/components/App.vue index 3df7376..f77e325 100644 --- a/app/javascript/components/App.vue +++ b/app/javascript/components/App.vue @@ -46,27 +46,7 @@ created() { if (this.user === null && this.authChecked === false) { this.checkAuthentication(); - } - - // Hard coded values taken directly from Bulma css - const mediaQueries = { - mobile: "screen and (max-width: 768px)", - tablet: "screen and (min-width: 769px)", - tabletOnly: "screen and (min-width: 769px) and (max-width: 1023px)", - touch: "screen and (max-width: 1023px)", - desktop: "screen and (min-width: 1024px)", - desktopOnly: "screen and (min-width: 1024px) and (max-width: 1215px)", - widescreen: "screen and (min-width: 1216px)", - widescreenOnly: "screen and (min-width: 1216px) and (max-width: 1407px)", - fullhd: "screen and (min-width: 1408px)" - }; - - for (let device in mediaQueries) { - const query = window.matchMedia(mediaQueries[device]); - query.onchange = (q) => { - this.$store.commit("setMediaQuery", {mediaName: device, value: q.matches}); - }; - query.onchange(query); + } }, diff --git a/app/javascript/components/AppModal.vue b/app/javascript/components/AppModal.vue index f015190..c9cf5bf 100644 --- a/app/javascript/components/AppModal.vue +++ b/app/javascript/components/AppModal.vue @@ -6,7 +6,7 @@ @@ -36,7 +36,7 @@ }, mounted() { - document.body.appendChild(this.$refs.modal); + this.$root.$el.appendChild(this.$refs.modal); }, beforeDestroy() { @@ -63,6 +63,8 @@ \ No newline at end of file diff --git a/app/javascript/components/TaskItemEdit.vue b/app/javascript/components/TaskItemEdit.vue index b0c1d18..298ce0c 100644 --- a/app/javascript/components/TaskItemEdit.vue +++ b/app/javascript/components/TaskItemEdit.vue @@ -17,7 +17,7 @@
- +
@@ -45,11 +45,15 @@ save() { this.$emit("save", this.taskItem); + }, + + focus() { + this.$refs.nameInput.focus(); } }, mounted() { - this.$refs.nameInput.focus(); + this.focus(); } } diff --git a/app/javascript/components/TaskItemList.vue b/app/javascript/components/TaskItemList.vue index 503fc77..e8348f3 100644 --- a/app/javascript/components/TaskItemList.vue +++ b/app/javascript/components/TaskItemList.vue @@ -2,10 +2,10 @@
- + - +
@@ -17,8 +17,12 @@ - - + + @@ -36,40 +40,83 @@
+
+ +
+
{{ i.name }} {{ i.quantity }}