From 23bc5d5feaba0eb64b29c48b81054b6c92058bc5 Mon Sep 17 00:00:00 2001 From: Nkululeko Date: Fri, 1 Nov 2019 16:39:31 +0200 Subject: [PATCH 1/3] Added the Label Name Card Filter feature --- .idea/.gitignore | 2 + .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/php.xml | 80 +++++++++++++ .idea/symfony2.xml | 7 ++ .idea/trello-tools.iml | 83 +++++++++++++ .idea/vcs.xml | 6 + .../Helper/CardFilter/LabelNameCardFilter.php | 110 ++++++++++++++++++ .../Helper/TrelloClient/TrelloClient.php | 23 +++- 9 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/symfony2.xml create mode 100644 .idea/trello-tools.iml create mode 100644 .idea/vcs.xml create mode 100644 src/AppBundle/Helper/CardFilter/LabelNameCardFilter.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b5cea1e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..9be4386 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/symfony2.xml b/.idea/symfony2.xml new file mode 100644 index 0000000..41c1b04 --- /dev/null +++ b/.idea/symfony2.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/trello-tools.iml b/.idea/trello-tools.iml new file mode 100644 index 0000000..53bff47 --- /dev/null +++ b/.idea/trello-tools.iml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/AppBundle/Helper/CardFilter/LabelNameCardFilter.php b/src/AppBundle/Helper/CardFilter/LabelNameCardFilter.php new file mode 100644 index 0000000..6df5e50 --- /dev/null +++ b/src/AppBundle/Helper/CardFilter/LabelNameCardFilter.php @@ -0,0 +1,110 @@ +get('trello_client'); + + $boardLabels = $trelloClient->getBoardLabels($boardId); + $options = []; + $count = 1; + foreach($boardLabels as $boardLabel ){ + $labelName = $boardLabel->getName(); + if ( isset($options[ $boardLabel->getName() ]) && ( isset( $labelName ) && !empty( $boardLabel->getName()) ) ) + { + $options[$count.' '.$boardLabel->getName() ] = $boardLabel; + } + elseif( isset( $labelName ) && !empty( $boardLabel->getName()) ) + { + $options[$count.' '.$boardLabel->getName()] = $boardLabel; + } + $count ++; + //$options[$boardLabel->getId()] = $boardLabel; + } + $filterOptionQuestion = new ChoiceQuestion( + 'Select Label to filter by:', + array_merge(array_keys($options), ['<- Back']) + ); + $questionHelper = new QuestionHelper(); + $selectedLabelName = $questionHelper->ask($input, $output, $filterOptionQuestion); + if($selectedLabelName == '<- Back'){ + throw new \Exception('Back option selected'); + } + + $filter = new self(); + $filter->targetLabel = $options[$selectedLabelName]; + + return $filter; + } + + /** + * Should return TRUE if the provided card passes this filter and FALSE otherwise + * + * @param Card $card + * + * @return boolean + */ + public function satisfiedBy(Card $card) + { + foreach ($card->getLabels() as $cardLabel){ + if ($cardLabel->getId() == $this->getTargetLabel()->getId()){ + return true; + } + } + return false; + } + + /** + * Should return a unique, static friendly name for the filter to identify it in interfaces + * + * @return string + */ + static public function getName() + { + return 'Has Label'; + } + + /** + * Should return a short description (around 50 characters or less) of what this specific instantiation of the filter + * is filtering for + * + * @return string + */ + public function getConfigDescription() + { + return 'Label: '.$this->getTargetLabel()->getName(); + } + + private function getTargetLabel() + { + return $this->targetLabel; + } +} diff --git a/src/AppBundle/Helper/TrelloClient/TrelloClient.php b/src/AppBundle/Helper/TrelloClient/TrelloClient.php index 160b81e..da87353 100644 --- a/src/AppBundle/Helper/TrelloClient/TrelloClient.php +++ b/src/AppBundle/Helper/TrelloClient/TrelloClient.php @@ -6,6 +6,7 @@ use AppBundle\Helper\TrelloClient\Model\Board; use AppBundle\Helper\TrelloClient\Model\BoardList; use AppBundle\Helper\TrelloClient\Model\Card; +use AppBundle\Helper\TrelloClient\Model\Label; use AppBundle\Helper\TrelloClient\Model\Member; use Doctrine\Common\Collections\ArrayCollection; use GuzzleHttp\Client; @@ -121,7 +122,7 @@ public function getBoardLists($boardId) * * @return Member[]|ArrayCollection */ - public function getBoardMembers($boardId) + public function getBoardMembers($boardId) { $queryParameters = [ 'fields' => 'id,avatarUrl,initials,fullName,username', @@ -134,6 +135,24 @@ public function getBoardMembers($boardId) ); } + /** + * @param $boardId + * + * @return Label[]\ArrayCollection + */ + public function getBoardLabels($boardId) + { + $queryParameters = [ + 'fields' => 'all', + ]; + return $this->makeRequest( + 'boards/'.$boardId.'/labels', + 'GET', + 'ArrayCollection', + $queryParameters + ); + } + protected function makeRequest($path, $method = 'GET', $expectedResponseClass = null, array $parameters = []) { @@ -194,4 +213,4 @@ protected function getSerializer() { return $this->serializer; } -} \ No newline at end of file +} From 250c72c4941c78bef7c3ca78c21cefae5cc107e9 Mon Sep 17 00:00:00 2001 From: Nkululeko Date: Mon, 4 Nov 2019 13:45:17 +0200 Subject: [PATCH 2/3] gitignored the ideas folder --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 1 + 2 files changed, 1 insertion(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4d3d5f4516e01e6609c74ac15c10e5871647dbcd GIT binary patch literal 6148 zcmeHKPfO!K6rX9Un^;&Pc<6$M0S{ivV%H*i3-!-QP)yN-t~DXi20|if+8#<8En zpjZEV5A{QM^hX;O?2a(GfuGjCJdQswy#ggM=GJtD0!G5xk`7B^B*YD9gjlxd0uyD@{#nQy&H^ZDN zo8|9i^S9GZ`cCF%-A=%9pbHg}DWj$5nU@wgQq~A!ovEPyLy12Br-K-6Dj5+)GLGo!DX3MG!2DO!? zs;Jk7RWYdjs@JPxd2wktG!5g&{Kn2<_s`$6^NY)?>ziA(3LHLHDbpH9a0kW*Gcq53=jifiUD3)bJiL#C4IJzO%Bgm0eS?Af^oUR=M*sH hQ4Fzo6jwl{fM1{iXlu+Bf(L|t1SAdA5CiYZz!N!IVBG)! literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore index 479b52f..62f7077 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /vendor/ /web/bundles/ composer.lock +.idea From 04240344cb06cd2fa72a9efb5433336d34291d18 Mon Sep 17 00:00:00 2001 From: Nkululeko Date: Mon, 4 Nov 2019 14:00:17 +0200 Subject: [PATCH 3/3] removed the idea file --- .idea/.gitignore | 2 - .idea/misc.xml | 6 --- .idea/modules.xml | 8 ---- .idea/php.xml | 80 ---------------------------------------- .idea/symfony2.xml | 7 ---- .idea/trello-tools.iml | 83 ------------------------------------------ .idea/vcs.xml | 6 --- 7 files changed, 192 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/symfony2.xml delete mode 100644 .idea/trello-tools.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 5c98b42..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 28a804d..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index b5cea1e..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 9be4386..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/symfony2.xml b/.idea/symfony2.xml deleted file mode 100644 index 41c1b04..0000000 --- a/.idea/symfony2.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/trello-tools.iml b/.idea/trello-tools.iml deleted file mode 100644 index 53bff47..0000000 --- a/.idea/trello-tools.iml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file