Skip to content
Snippets Groups Projects
Commit 67fd7b84 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

reorder

parent 27657484
No related branches found
No related tags found
No related merge requests found
......@@ -17,12 +17,10 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web
pages.concat(page.descendents) if parent_id != page.parent_id
page.update(
parent_id: parent_id,
position: index + 1,
skip_github_publication: true
position: index + 1
)
end
github = Github.with_website @website
github.send_batch_to_website(pages, message: '[Page] Reorder pages.')
pages.first.sync_with_git
end
def children
......
......@@ -76,7 +76,7 @@ class Communication::Website::Page < ApplicationRecord
end
def git_dependencies(identifier)
descendents
descendents + siblings
end
def list_of_other_pages
......
......@@ -40,17 +40,6 @@ module WithGit
destroy
end
protected
# Overridden for multiple files generation
def identifiers
[:static]
end
def git_dependencies(identifier)
[]
end
def sync_with_git
websites.each do |website|
identifiers.each do |identifier|
......@@ -63,4 +52,15 @@ module WithGit
end
end
handle_asynchronously :sync_with_git
protected
# Overridden for multiple files generation
def identifiers
[:static]
end
def git_dependencies(identifier)
[]
end
end
......@@ -23,6 +23,10 @@ module WithTree
: []
end
def siblings
self.class.where(parent: parent).where.not(id: id)
end
def self_and_children(level)
elements = []
label = "&nbsp;&nbsp;&nbsp;" * level + self.to_s
......
......@@ -69,8 +69,12 @@ end
```
Pour les reorder :
Pour les reorder, chaque objet doit avoir ses siblings en dépendance, donc il suffit de synchroniser un objet déplacé pour qu'il gère l'ensemble :
```
def reorder
...
pages.first.sync_with_git
end
```
TODO gérer la suppression correctement
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment