Commit ee63e028 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1991603: Outcomes portfolio (3) - Signoff circle to have inner dot



On the outcome overview page

Also add an access denied if the values of the 'Add activity' button
are manipulated and there isn't a matching group/collection/outcome

Also fixing issue when outcome type is not selected and we are viewing
the activity page

Change-Id: Id1b4e8a30947b81bef76c92b27929bdf37068518
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 741c85c9
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -1186,8 +1186,8 @@ class View {
                  {view_activity} va
                  JOIN {outcome_view_activity} ov ON va.id = ov.activity
                  JOIN {outcome} o ON o.id = ov.outcome
                  JOIN {outcome_type} ot ON ot.id = o.outcome_type
                  JOIN {outcome_subject} os ON os.id = va.subject
                  LEFT JOIN {outcome_type} ot ON ot.id = o.outcome_type
                  WHERE va.view = ?
            ";

@@ -4197,6 +4197,23 @@ class View {
        return true;
    }

    /**
     * Check if the outcome and collection exist for the group
     *
     * @param  mixed $groupid
     * @param  mixed $outcomeid
     * @param  mixed $collectionid
     * @throws AccessDeniedException
     */
    public static function check_group_outcome_collection($groupid, $outcomeid, $collectionid): bool {
        if (get_record_sql("SELECT o.id FROM {collection} c
                            JOIN {outcome} o ON o.collection = c.id
                            WHERE c.group = ? AND o.collection = ? AND o.id = ?", array($groupid, $collectionid, $outcomeid))) {
            return true;
        }
        throw new AccessDeniedException();
    }

    /**
     * Generate activity support data
     */
+18 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ $(function() {
          $('tr[data-activity=' + activityid + ']').html(data.html);
          // link modal to icon
          $('tr[data-activity=' + activityid + '] a.activity-incomplete').map((_, link)=> incomplete_activity_click_event(link));
          set_icon_states();
        }
      }, function(error) {
        console.log(error);
@@ -257,4 +258,21 @@ $(function() {
    formchangemanager.add(formid);
  })

function set_icon_states() {
    $('.activity-state.activity-incomplete span').off();
    $('.outcome-state.outcome-incomplete span').off();
    $('.activity-state.activity-incomplete span').on('mouseover', function() {
        $(this).removeClass('icon-circle').addClass('icon-dot-circle');
    });
    $('.activity-state.activity-incomplete span').on('mouseout', function() {
        $(this).removeClass('icon-dot-circle').addClass('icon-circle');
    });
    $('.outcome-state.outcome-incomplete span').on('mouseover', function() {
        $(this).removeClass('icon-check-circle').addClass('icon-dot-circle');
    });
    $('.outcome-state.outcome-incomplete span').on('mouseout', function() {
        $(this).removeClass('icon-dot-circle').addClass('icon-circle');
    });
}
set_icon_states();
</script>
+2 −0
Original line number Diff line number Diff line
@@ -7,11 +7,13 @@
        </h2>
        <div class="activity-outcome-line">
            <div class="outcome-text">{str tag="outcome" section="collection"}: {$activity->outcome}</div>
            {if $activity->outcome_type}
            <div class="outcome-text">{str tag="outcometype" section="collection"}:
                <div id="outcometype-{$outcome->id}" class="outcome-type">
                    <span class="badge rounded-pill text-bg-{$activity->styleclass}">{$activity->outcome_type}</span>
                </div>
            </div>
            {/if}
            <div class="activity-outcome-signoff">{$activity_signoff_html|safe}</div>
        </div>
        <div class="block collapse hide" id="target" aria-expanded="true">
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ if ($new && $id === false) {

        if ($view_type == 'activity') {
            View::check_can_edit_activity_page_info($groupid);
            View::check_group_outcome_collection($groupid, $outcome, $collection_to_add_view);
            $values['outcome'] = $outcome;
        }