diff --git a/classes/AlertView/NewAlert.php b/classes/AlertView/NewAlert.php index 2b89d4e39a..16a372f2dc 100644 --- a/classes/AlertView/NewAlert.php +++ b/classes/AlertView/NewAlert.php @@ -63,15 +63,22 @@ private function processAction() { protected function searchForConstituenciesAndMembers() { // Do the search - if ($this->data['representative']) { + $errors = []; + if ($this->data['pid']) { + $MEMBER = new \MEMBER(['person_id' => $this->data['pid']]); + $this->data['members'] = [[ + "person_id" => $MEMBER->person_id, + "given_name" => $MEMBER->given_name, + "family_name" => $MEMBER->family_name, + ]]; + } elseif ($this->data['representative']) { $this->data['members'] = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookupWithNames($this->data['representative'], true); - if (count($this->data['members']) == 0) { - if (sizeof($this->data["errors"])) { - $this->data["errors"]["representative"] = "No matching representative found"; - } else { - $this->data["errors"] = ["representative" => "No matching representative found"]; - } + $member_count = count($this->data['members']); + if ($member_count == 0) { + $errors["representative"] = gettext("No matching representative found"); + } elseif ($member_count > 1) { + $errors["representative"] = gettext("Multiple matching representatives found, please select one."); } else { $this->data['pid'] = $this->data['members'][0]['person_id']; } @@ -79,7 +86,11 @@ protected function searchForConstituenciesAndMembers() { $this->data['members'] = []; } - error_log(print_r($this->data['members'], true)); + if (count($this->data["errors"]) > 0) { + $this->data["errors"] = array_merge($this->data["errors"], $errors); + } else { + $this->data["errors"] = $errors; + } } private function wrap_phrase_in_quotes($phrase) { diff --git a/www/docs/style/sass/parts/_accordion.scss b/www/docs/style/sass/parts/_accordion.scss index b0450b0958..f6d797785e 100644 --- a/www/docs/style/sass/parts/_accordion.scss +++ b/www/docs/style/sass/parts/_accordion.scss @@ -174,6 +174,11 @@ button { } +.alert-page-option-label { + display: inline; + margin-left: 0.5em; +} + .button.red { background-color: $color-red; color: #fff; diff --git a/www/includes/easyparliament/templates/html/alert/new.php b/www/includes/easyparliament/templates/html/alert/new.php index 60c073eda2..08546c87c2 100644 --- a/www/includes/easyparliament/templates/html/alert/new.php +++ b/www/includes/easyparliament/templates/html/alert/new.php @@ -203,12 +203,23 @@ -
- - - - +
+ + + 0) { ?> + + $member) { + $name = member_full_name($member['house'], $member['title'], $member['given_name'], $member['family_name'], $member['lordofname']); + if ($member['constituency']) { + $name .= ' (' . gettext($member['constituency']) . ')'; + } ?> + +
+ + +

+