|
@@ -248,12 +248,12 @@ class GenerateTreeCommand extends Command
|
|
|
}
|
|
|
else if(strpos($line, "!grp:") === 0) { // !grp:
|
|
|
if (!empty($currentMethod)) {
|
|
|
- $currentMethod->addGroup(substr($line, 5));
|
|
|
+ $currentMethod->addGroup(substr($line, 5), $exitURL);
|
|
|
}
|
|
|
}
|
|
|
else if(strpos($line, "!act:") === 0) { // !act:
|
|
|
if (!empty($currentMethod)) {
|
|
|
- $currentMethod->addColumnAction(substr($line, 5), $exitURL);
|
|
|
+ $currentMethod->addAction(substr($line, 5), $exitURL);
|
|
|
}
|
|
|
}
|
|
|
else if(strpos($line, "!nal:") === 0) { // !nal:
|
|
@@ -751,6 +751,28 @@ class GenController {
|
|
|
foreach ($method->groups as $group) {
|
|
|
$groupHtml = $groupTemplate;
|
|
|
$groupHtml = str_replace("<!-- __GROUP_NAME__ -->", $group["name"], $groupHtml);
|
|
|
+ if (isset($group["action"])) {
|
|
|
+ $action = $group["action"];
|
|
|
+ $actionLine = [];
|
|
|
+ if (isset($action["condition"])) {
|
|
|
+ if ($action["condition"] === "if") {
|
|
|
+ $actionLine[] = "@if(";
|
|
|
+ } else {
|
|
|
+ $actionLine[] = "@if(!";
|
|
|
+ }
|
|
|
+ $actionLine[] = "\$record->{$action["field"]})";
|
|
|
+ }
|
|
|
+ $actionLine[] = "<a " .
|
|
|
+ 'up-modal=".form-contents" up-width="800" up-history="false" ' .
|
|
|
+ "href='{$action["link"]}' title='{$action["label"]}' class='ml-2 text-dark font-weight-normal'>" .
|
|
|
+ "<i class='fa fa-{$action["icon"]} text-sm'></i>" .
|
|
|
+ "</a>";
|
|
|
+ if (isset($action["condition"])) {
|
|
|
+ $actionLine[] = "@endif";
|
|
|
+ }
|
|
|
+ $actionLine = implode(" ", $actionLine);
|
|
|
+ $groupHtml = str_replace("<!-- __GROUP_ACTION__ -->", $actionLine, $groupHtml);
|
|
|
+ }
|
|
|
$fields = [];
|
|
|
foreach ($group["fields"] as $field) {
|
|
|
|
|
@@ -774,16 +796,6 @@ class GenController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- "is_active" => array:1 [
|
|
|
- 0 => array:5 [
|
|
|
- "label" => "Deactivate"
|
|
|
- "icon" => "edit"
|
|
|
- "condition" => "if"
|
|
|
- "field" => "is_active"
|
|
|
- ]
|
|
|
- ]
|
|
|
- */
|
|
|
if(isset($method->columnActions[$field])) {
|
|
|
foreach($method->columnActions[$field] as $action) {
|
|
|
$actionLine = [];
|
|
@@ -1066,16 +1078,26 @@ class GenControllerMethod {
|
|
|
}
|
|
|
$this->columns[$parts[0]] = $spec;
|
|
|
}
|
|
|
- public function addGroup($line) {
|
|
|
+ public function addGroup($line, $link) {
|
|
|
// Basic Details:id,uid,created_at,clients_count
|
|
|
$parts = explode(":", $line);
|
|
|
- $this->groups[] = [
|
|
|
+ $group = [
|
|
|
"name" => $parts[0],
|
|
|
"fields" => explode(",", $parts[1])
|
|
|
];
|
|
|
+ // is there a group action
|
|
|
+ if(count($parts) > 2) {
|
|
|
+ $actionParts = ["-"];
|
|
|
+ for($i = 2; $i < count($parts); $i++) {
|
|
|
+ $actionParts[] = $parts[$i];
|
|
|
+ }
|
|
|
+ $actionParts = implode(":", $actionParts);
|
|
|
+ $group["action"] = $this->addAction($actionParts, $link, true);
|
|
|
+ }
|
|
|
+ $this->groups[] = $group;
|
|
|
$this->dashboard = true;
|
|
|
}
|
|
|
- public function addColumnAction($line, $link) {
|
|
|
+ public function addAction($line, $link, $group = false) {
|
|
|
// is_active:Deactivate:deactivate:edit:if:is_active
|
|
|
$parts = explode(":", $line);
|
|
|
$action = [
|
|
@@ -1089,9 +1111,12 @@ class GenControllerMethod {
|
|
|
if($link) {
|
|
|
$action['link'] = preg_replace("/\\$([a-zA-Z0-9_]+)/", "<?= \$record->$1 ?>", $link);
|
|
|
}
|
|
|
- if(!isset($this->columnActions[$parts[0]])) {
|
|
|
- $this->columnActions[$parts[0]] = [];
|
|
|
+ if(!$group) {
|
|
|
+ if(!isset($this->columnActions[$parts[0]])) {
|
|
|
+ $this->columnActions[$parts[0]] = [];
|
|
|
+ }
|
|
|
+ $this->columnActions[$parts[0]][] = $action;
|
|
|
}
|
|
|
- $this->columnActions[$parts[0]][] = $action;
|
|
|
+ return $action;
|
|
|
}
|
|
|
}
|