From 1564af069472e32ed322bf9acedc9c487bce1a15 Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 6 Oct 2020 19:29:04 +0200 Subject: First pass at listing Resources This implements resource listing and pagination. See /resources --- app/controllers/resources_controller.rb | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb index 1253b5d..d7fd822 100644 --- a/app/controllers/resources_controller.rb +++ b/app/controllers/resources_controller.rb @@ -1,13 +1,55 @@ class ResourcesController < ApplicationController + before_action :set_resource, only: [:new, :edit, :update, :delete, :destroy] + + # GET /resources def index + @resources = Resource.order(:uuid).page params[:page] end + # GET /resources/new def new end + # POST /resources + def create + # Check list: + # 1. UUID is not set, or not known + # 2. Agent is correct + # 3. Name, Description, Phone, Email, etc. do not yield results + # 4. Background job to validate fields and save + # 5. Or Background job to list similar items + # 6. Return to user with new record or list of mergeable ones + end + + # GET /resources/:id + def show + end + + # GET /resources/:id/edit def edit end + # PATCH /resources/:id + def update + # Check list: + # 1. Compare records for changes + # 2. Validate each change + # 3. Moderate queue or save + end + + # GET /resources/:id/delete def delete end + + # DELETE /resources/:id + def destroy + # Check list + # 1. User belongs to Agent and is :maintainer? + end + + private + + def set_resource + @resource = Resource.find_by(uuid: params[:id]) || Resource.new + end end -- cgit v1.2.3