Links, mainly...
This commit is contained in:
parent
fd42a3f173
commit
21ab02d647
69 changed files with 2258 additions and 155 deletions
|
|
@ -13,7 +13,9 @@ class ApplicationController < ActionController::Base
|
|||
{ label: 'Dashboard', icon: :speedometer2, path: :root },
|
||||
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
||||
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
||||
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks }
|
||||
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks },
|
||||
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
|
||||
{ label: LinkCategory.model_name.human(count: 2), icon: :"folder", path: :link_categories }
|
||||
]
|
||||
@search_url = nil # root_url
|
||||
end
|
||||
|
|
|
|||
58
app/controllers/link_categories_controller.rb
Normal file
58
app/controllers/link_categories_controller.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
class LinkCategoriesController < ApplicationController
|
||||
before_action :set_link_category, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /link_categories
|
||||
def index
|
||||
@link_categories = LinkCategory.all
|
||||
end
|
||||
|
||||
# GET /link_categories/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /link_categories/new
|
||||
def new
|
||||
@link_category = LinkCategory.new
|
||||
end
|
||||
|
||||
# GET /link_categories/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /link_categories
|
||||
def create
|
||||
@link_category = LinkCategory.new(link_category_params)
|
||||
|
||||
if @link_category.save
|
||||
redirect_to @link_category, notice: "Link category was successfully created."
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /link_categories/1
|
||||
def update
|
||||
if @link_category.update(link_category_params)
|
||||
redirect_to @link_category, notice: "Link category was successfully updated.", status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /link_categories/1
|
||||
def destroy
|
||||
@link_category.destroy!
|
||||
redirect_to link_categories_url, notice: "Link category was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_link_category
|
||||
@link_category = LinkCategory.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def link_category_params
|
||||
params.require(:link_category).permit(:name, :description, :rich_text)
|
||||
end
|
||||
end
|
||||
59
app/controllers/links_controller.rb
Normal file
59
app/controllers/links_controller.rb
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
class LinksController < ApplicationController
|
||||
before_action :set_link, only: %i[show edit update destroy]
|
||||
|
||||
# GET /links
|
||||
def index
|
||||
@links = Link.all
|
||||
end
|
||||
|
||||
# GET /links/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /links/new
|
||||
def new
|
||||
@link = Link.new
|
||||
end
|
||||
|
||||
# GET /links/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /links
|
||||
def create
|
||||
@link = Link.new(link_params)
|
||||
|
||||
if @link.save
|
||||
redirect_to @link, notice: 'Link was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /links/1
|
||||
def update
|
||||
if @link.update(link_params)
|
||||
redirect_to @link, notice: 'Link was successfully updated.', status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /links/1
|
||||
def destroy
|
||||
@link.destroy!
|
||||
redirect_to links_url, notice: 'Link was successfully destroyed.', status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_link
|
||||
@link = Link.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def link_params
|
||||
params.require(:link).permit(:url, :text, :description_html, :last_check_at, :fail_count, :link_category_id)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue