Skip to content

Commit ae663c4

Browse files
author
hikki
committed
v3
1 parent 7843d39 commit ae663c4

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

src/Widget/CascadeDot.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CascadeDot extends DLPField
1616
public function render()
1717
{
1818
$id = $this->formatName($this->id);
19-
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '250px';
19+
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '230px';
2020
$limit = isset($this->attributes['limit']) ? (int)$this->attributes['limit'] : 0;
2121
$this->addVariables(['height'=>$height]);
2222
$select = json_encode($this->options, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
@@ -26,4 +26,22 @@ public function render()
2626
EOT;
2727
return parent::render();
2828
}
29+
30+
public static function panel(array $selected,array $select,int $limit=1,array $style=[])
31+
{
32+
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
33+
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
34+
$style = array_merge(['height'=>'230px'],$style);
35+
$style_string = '';
36+
foreach ($style as $k=>$s){
37+
$style_string.="$k:$s;";
38+
}
39+
$id = 'cascade_dot_'.mt_rand(0,100);
40+
return <<<EOF
41+
<div id="{$id}" style="$style_string"></div>
42+
<script>
43+
new ComponentCascadeDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
44+
</script>
45+
EOF;
46+
}
2947
}

src/Widget/CascadeLine.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CascadeLine extends DLPField
1616
public function render()
1717
{
1818
$id = $this->formatName($this->id);
19-
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '250px';
19+
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '230px';
2020
$this->addVariables(['height'=>$height]);
2121
$select = json_encode($this->options, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2222
$xhr = $this->xhr ?? '';
@@ -25,4 +25,21 @@ public function render()
2525
EOT;
2626
return parent::render();
2727
}
28+
29+
public static function panel(array $select,string $xhr,array $style=[])
30+
{
31+
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
32+
$style = array_merge(['height'=>'230px'],$style);
33+
$style_string = '';
34+
foreach ($style as $k=>$s){
35+
$style_string.="$k:$s;";
36+
}
37+
$id = 'cascade_line_'.mt_rand(0,100);
38+
return <<<EOF
39+
<div id="{$id}" style="$style_string"></div>
40+
<script>
41+
new ComponentCascadeLine("{$id}",JSON.parse('{$select}'),'{$xhr}');
42+
</script>
43+
EOF;
44+
}
2845
}

src/Widget/Dot.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,21 @@ public function render()
2626
EOT;
2727
return parent::render();
2828
}
29+
30+
public static function panel(array $selected,array $select,int $limit=1,array $style=[])
31+
{
32+
$select = json_encode($select, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
33+
$style = array_merge(['height'=>'200px'],$style);
34+
$style_string = '';
35+
foreach ($style as $k=>$s){
36+
$style_string.="$k:$s;";
37+
}
38+
$id = 'dot_'.mt_rand(0,100);
39+
return <<<EOF
40+
<div id="{$id}" style="$style_string"></div>
41+
<script>
42+
new ComponentDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
43+
</script>
44+
EOF;
45+
}
2946
}

src/Widget/Linear.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@ public function render()
3838
EOT;
3939
return parent::render();
4040
}
41+
42+
public static function panel(array $columns,array $data,array $options=['sortable' => true, 'delete' => true])
43+
{
44+
$columns = json_encode($columns);
45+
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
46+
$options = json_encode(array_merge(['sortable' => true, 'delete' => true],$options));
47+
$id = 'dot_'.mt_rand(0,100);
48+
return <<<EOF
49+
<div id="{$id}" style="$style_string"></div>
50+
<script>
51+
new ComponentLine("{$id}",JSON.parse('{$columns}'),JSON.parse('{$data}'),JSON.parse('{$options}'));
52+
</script>
53+
EOF;
54+
}
4155
}

0 commit comments

Comments
 (0)