This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ability to archive pages * Refactored Page#active boolean flag to be a Page#publish_status, which is an enum with 3 possible statuses. * Add ability to archive and unarchive pages. * Add ability to search pages filtering by `publish_status * Add confirm pop-up to archive link * Use new enum on page service class
- Loading branch information
Showing
36 changed files
with
298 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class PageArchivesController < ApplicationController | ||
before_action :authenticate_user! | ||
def create | ||
@page = Page.find(params[:page_id]) | ||
@page.archived! | ||
redirect_to pages_path, notice: 'Page was successfully archived.' | ||
end | ||
|
||
def destroy | ||
@page = Page.find(params[:page_id]) | ||
@page.unpublished! | ||
redirect_to pages_path, notice: 'Page was successfully unarchived.' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
json.array! @pages do |page| | ||
json.extract! page, :id, :title, :slug, :content, :created_at, :updated_at, :active, :featured, :action_count | ||
json.extract! page, :id, :title, :slug, :content, :created_at, :updated_at, :publish_status, :featured, :action_count | ||
json.language page.language.code | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
json.extract! @page, :id, :title, :slug, :content, :created_at, :updated_at, :active, :featured, :action_count | ||
json.language @page.language.code | ||
json.extract! @page, :id, :title, :slug, :content, :created_at, :updated_at, :publish_status, :featured, :action_count | ||
json.language @page.language.code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class AddPublishStatusToPages < ActiveRecord::Migration | ||
class Page < ActiveRecord::Base | ||
end | ||
|
||
def up | ||
add_column :pages, :publish_status, :integer, default: 1, null: false | ||
add_index :pages, :publish_status | ||
Page.where(active: true).update_all(publish_status: 0) | ||
Page.where(active: false).update_all(publish_status: 1) | ||
remove_column :pages, :active | ||
end | ||
|
||
def down | ||
add_column :pages, :active, :boolean, default: false | ||
add_index :pages, :active | ||
remove_column :pages, :publish_status | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.