Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1b387a7
start creating move class function. should it sync children or add them?
aryarm Mar 2, 2019
6551469
start creating class attachment validation function
aryarm Mar 3, 2019
b248935
remove sync parameter. it doesn't make sense for the class tree
aryarm Mar 9, 2019
960b82b
fix some comments
aryarm Mar 10, 2019
c157772
when seeding classes, prevent the creation of stick trees and provide…
aryarm Mar 10, 2019
ddbd1ce
create class attachment validation function. still untested but shoul…
aryarm Mar 10, 2019
da314c3
allow class seeding to create sticks if desired
aryarm Mar 10, 2019
c6f0852
redo isAncestor in ClassRepository to take advantage of the structure…
aryarm Mar 18, 2019
dfbc3c2
implement array input in the ClassRepository's isDescendant() and isA…
aryarm Mar 18, 2019
bb429d3
enable ClassRepository's isAncestor() and isDescendant() to optionall…
aryarm Mar 18, 2019
b33025b
finish up issue #140
aryarm Mar 18, 2019
d1d0851
create helper functions for separated connections format. see issue #140
aryarm Mar 18, 2019
473b592
use separated connections in ClassRepository
aryarm Mar 19, 2019
5a23bcc
create readable array helper function
aryarm Mar 19, 2019
1a2995c
handle the root case in class attachment validation
aryarm Mar 19, 2019
1fc8521
create custom validation rule, but it may need to be split according …
aryarm Mar 19, 2019
29ba5e9
create split validation rules for class attachment
aryarm Mar 19, 2019
8569451
split class attachment validation rules
aryarm Mar 19, 2019
e333c58
integrate the class validation rules into the ClassController's attac…
aryarm Mar 19, 2019
7ce5cd5
start testing class attachment (see #136)
aryarm Mar 20, 2019
9e7e1e3
use old classes http test to verify class attachment still works
aryarm Mar 20, 2019
3f627aa
scaffold class attachment http test. still need to write the actual t…
aryarm Mar 20, 2019
d399cb0
fix some bugs with class attachment
aryarm Mar 20, 2019
c894325
finish testing class attachment validation
aryarm Mar 20, 2019
61b0d7a
improve comments in the class attachment http test
aryarm Mar 21, 2019
821b67a
remove class attachment tests in classes http test, since we already …
aryarm Mar 21, 2019
663c7ba
reduce queries in ClassController's attach() function
aryarm Mar 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
create helper functions for separated connections format. see issue #140
  • Loading branch information
aryarm committed Mar 18, 2019
commit d1d085160dea9afe2def0174e8d748632dfe4f04
28 changes: 28 additions & 0 deletions app/Helpers/NodesAndConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ public static function treeAsConnections($old_nodes)
return self::convertTo($old_nodes)["connections"];
}

/**
* put ancestor and descendant data in the separated connections format
* @param Collection $ancestors the ancestor data
* @param Collection $descendants the descendant data
* @return Collection the ancestors and descendants in the separated connections format, representing a portion of the tree
*/
public static function treeAsSeparatedConnections($ancestors, $descendants)
{
return collect([
'ancestors' => self::treeAsConnections($ancestors),
'descendants' => self::treeAsConnections($descendants)
]);
}

/**
* return a tree as separate connections
* @param string $repository the name of the class to use to get the ancestors and descendants from
* @param array $args any arguments to pass to the ancestors and descendants functions
* @return Collection the tree in the separated connections format
*/
public static function separatedTree($repository, ...$args)
{
return self::treeAsSeparatedConnections(
(new $repository)->ancestors(...$args),
(new $repository)->descendants(...$args)
);
}

/**
* some data won't have pivot objects, but conversion function depends on their existence
* let's format an $node into the "nodes with pivot" format
Expand Down