From 1887d8bdeb4e5bae144d2d4448c1a0008c00196f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 19 Nov 2020 16:28:53 -0800 Subject: [PATCH] afform/core - Add property 'is_dashlet' --- ext/afform/core/CRM/Afform/AfformScanner.php | 1 + ext/afform/core/Civi/Api4/Action/Afform/Get.php | 1 + ext/afform/core/Civi/Api4/Afform.php | 4 ++++ ext/afform/docs/crud.md | 1 + ext/afform/mock/ang/mockPage.aff.json | 2 +- ext/afform/mock/tests/phpunit/api/v4/AfformTest.php | 7 +++++-- 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ext/afform/core/CRM/Afform/AfformScanner.php b/ext/afform/core/CRM/Afform/AfformScanner.php index 4ee84cbda4..97908d4932 100644 --- a/ext/afform/core/CRM/Afform/AfformScanner.php +++ b/ext/afform/core/CRM/Afform/AfformScanner.php @@ -132,6 +132,7 @@ class CRM_Afform_AfformScanner { 'requires' => [], 'title' => '', 'description' => '', + 'is_dashlet' => FALSE, 'is_public' => FALSE, 'permission' => 'access CiviCRM', ]; diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Get.php b/ext/afform/core/Civi/Api4/Action/Afform/Get.php index 5923017e2a..192c4cce31 100644 --- a/ext/afform/core/Civi/Api4/Action/Afform/Get.php +++ b/ext/afform/core/Civi/Api4/Action/Afform/Get.php @@ -114,6 +114,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { 'requires' => [], 'title' => ts('%1 block (default)', [1 => $custom['title']]), 'description' => '', + 'is_dashlet' => FALSE, 'is_public' => FALSE, 'permission' => 'access CiviCRM', 'join' => 'Custom_' . $custom['name'], diff --git a/ext/afform/core/Civi/Api4/Afform.php b/ext/afform/core/Civi/Api4/Afform.php index 3527442f41..94abb0467b 100644 --- a/ext/afform/core/Civi/Api4/Afform.php +++ b/ext/afform/core/Civi/Api4/Afform.php @@ -131,6 +131,10 @@ class Afform extends Generic\AbstractEntity { [ 'name' => 'description', ], + [ + 'name' => 'is_dashlet', + 'data_type' => 'Boolean', + ], [ 'name' => 'is_public', 'data_type' => 'Boolean', diff --git a/ext/afform/docs/crud.md b/ext/afform/docs/crud.md index 7ba2f3c09d..c51e70f09a 100644 --- a/ext/afform/docs/crud.md +++ b/ext/afform/docs/crud.md @@ -13,6 +13,7 @@ $ cv api4 afform.get +w name=helloWorld ], "title": "", "description": "", + "is_dashlet": false, "is_public": false, "server_route": "civicrm/hello-world", "layout": { diff --git a/ext/afform/mock/ang/mockPage.aff.json b/ext/afform/mock/ang/mockPage.aff.json index 2bdf31cc78..d24584b494 100644 --- a/ext/afform/mock/ang/mockPage.aff.json +++ b/ext/afform/mock/ang/mockPage.aff.json @@ -1 +1 @@ -{"server_route": "civicrm/mock-page", "requires":["mockBespoke"], "permission": "access Foobar" } +{"server_route": "civicrm/mock-page", "requires":["mockBespoke"], "permission": "access Foobar", "is_dashlet": true } diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php index 19de132180..d80e994395 100644 --- a/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformTest.php @@ -30,8 +30,8 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { public function getBasicDirectives() { return [ - ['mockPage', ['title' => '', 'description' => '', 'server_route' => 'civicrm/mock-page', 'permission' => 'access Foobar']], - ['mockBareFile', ['title' => '', 'description' => '', 'permission' => 'access CiviCRM']], + ['mockPage', ['title' => '', 'description' => '', 'server_route' => 'civicrm/mock-page', 'permission' => 'access Foobar', 'is_dashlet' => TRUE]], + ['mockBareFile', ['title' => '', 'description' => '', 'permission' => 'access CiviCRM', 'is_dashlet' => FALSE]], ['mockFoo', ['title' => '', 'description' => '', 'permission' => 'access CiviCRM']], ['mock-weird-name', ['title' => 'Weird Name', 'description' => '', 'permission' => 'access CiviCRM']], ]; @@ -58,6 +58,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { $this->assertEquals($get($originalMetadata, 'title'), $get($result[0], 'title'), $message); $this->assertEquals($get($originalMetadata, 'description'), $get($result[0], 'description'), $message); $this->assertEquals($get($originalMetadata, 'server_route'), $get($result[0], 'server_route'), $message); + $this->assertEquals($get($originalMetadata, 'is_dashlet'), $get($result[0], 'is_dashlet'), $message); $this->assertEquals($get($originalMetadata, 'permission'), $get($result[0], 'permission'), $message); $this->assertTrue(is_array($result[0]['layout']), $message); $this->assertEquals(TRUE, $get($result[0], 'has_base'), $message); @@ -68,6 +69,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { ->addWhere('name', '=', $formName) ->addValue('description', 'The temporary description') ->addValue('permission', 'access foo') + ->addValue('is_dashlet', TRUE) ->execute(); $this->assertEquals($formName, $result[0]['name'], $message); $this->assertEquals('The temporary description', $result[0]['description'], $message); @@ -77,6 +79,7 @@ class api_v4_AfformTest extends api_v4_AfformTestCase { $this->assertEquals($formName, $result[0]['name'], $message); $this->assertEquals($get($originalMetadata, 'title'), $get($result[0], 'title'), $message); $this->assertEquals('The temporary description', $get($result[0], 'description'), $message); + $this->assertEquals(TRUE, $get($result[0], 'is_dashlet'), $message); $this->assertEquals($get($originalMetadata, 'server_route'), $get($result[0], 'server_route'), $message); $this->assertEquals('access foo', $get($result[0], 'permission'), $message); $this->assertTrue(is_array($result[0]['layout']), $message); -- 2.25.1