diff --git a/module/screen/control.php b/module/screen/control.php index 36685ed29d..04646cbb3a 100644 --- a/module/screen/control.php +++ b/module/screen/control.php @@ -124,8 +124,15 @@ class screen extends control { $chartID = $this->post->sourceID; $type = $this->post->type; - $queryType = isset($_POST['queryType']) ? $this->post->queryType : 'filter'; - $component = isset($_POST['component']) ? json_decode($this->post->component) : null; + + if($type == 'Filters') + { + $filterComponent = $this->screen->genFilterComponent($chartID); + return print(json_encode($filterComponent)); + } + + $queryType = isset($_POST['queryType']) ? $this->post->queryType : 'filter'; + $component = isset($_POST['component']) ? json_decode($this->post->component) : null; $type = $this->screen->getChartType($type); diff --git a/module/screen/lang/de.php b/module/screen/lang/de.php index 0f108e262c..7568724770 100644 --- a/module/screen/lang/de.php +++ b/module/screen/lang/de.php @@ -9,3 +9,4 @@ $lang->screen->allUsers = 'All users'; $lang->screen->noData = 'No Data'; $lang->screen->noDesc = 'No Desc'; $lang->screen->bizGuide = 'For more Organization-wide Overview Reports please contact us'; +$lang->screen->globalFilter = 'Global Filter'; diff --git a/module/screen/lang/en.php b/module/screen/lang/en.php index 0f108e262c..7568724770 100644 --- a/module/screen/lang/en.php +++ b/module/screen/lang/en.php @@ -9,3 +9,4 @@ $lang->screen->allUsers = 'All users'; $lang->screen->noData = 'No Data'; $lang->screen->noDesc = 'No Desc'; $lang->screen->bizGuide = 'For more Organization-wide Overview Reports please contact us'; +$lang->screen->globalFilter = 'Global Filter'; diff --git a/module/screen/lang/fr.php b/module/screen/lang/fr.php index 0f108e262c..7568724770 100644 --- a/module/screen/lang/fr.php +++ b/module/screen/lang/fr.php @@ -9,3 +9,4 @@ $lang->screen->allUsers = 'All users'; $lang->screen->noData = 'No Data'; $lang->screen->noDesc = 'No Desc'; $lang->screen->bizGuide = 'For more Organization-wide Overview Reports please contact us'; +$lang->screen->globalFilter = 'Global Filter'; diff --git a/module/screen/lang/zh-cn.php b/module/screen/lang/zh-cn.php index 855a97a439..b70167e583 100644 --- a/module/screen/lang/zh-cn.php +++ b/module/screen/lang/zh-cn.php @@ -9,3 +9,4 @@ $lang->screen->allUsers = '所有用户'; $lang->screen->noData = '暂时没有数据'; $lang->screen->noDesc = '暂无描述'; $lang->screen->bizGuide = '更多大屏请联系我们'; +$lang->screen->globalFilter = '全局筛选器'; diff --git a/module/screen/model.php b/module/screen/model.php index c372e5bb27..1e7b800741 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -286,6 +286,40 @@ class screenModel extends model return $component; } + /** + * 生成全局筛选器的组件。 + * Generate component of global filters. + * + * @param string $filterType + * @access public + * @return object + */ + public function genFilterComponent($filterType) + { + $type = ucfirst($filterType); + + $component = new stdclass(); + $component->chartConfig = new stdclass(); + $component->chartConfig->id = $type; + $component->chartConfig->key = "{$type}Filter"; + $component->chartConfig->chartKey = "V{$type}Filter"; + $component->chartConfig->conKey = "VC{$type}Filter"; + $component->chartConfig->category = 'Filters'; + $component->chartConfig->categoryName = $this->lang->screen->globalFilter; + $component->chartConfig->package = 'Decorates'; + + $objectPairs = $this->loadModel('metric')->getPairsByScope($filterType); + $component->chartConfig->objectList = array_map(function($objectID, $objectTitle) + { + $object = new stdclass(); + $object->label = $objectTitle; + $object->value = $objectID; + return $object; + }, array_keys($objectPairs), array_values($objectPairs)); + + return $component; + } + /** * Generate metric component. *