getFilterParams()

in ee/app/assets/javascripts/roadmap/mixins/filtered_search_mixin.js [393:472]


    getFilterParams(filters = []) {
      const filterParams = {};
      const labels = [];
      const orAuthors = [];
      const notLabels = [];
      const orLabels = [];

      filters.forEach((filter) => {
        const { operator, data } = filter.value;
        switch (filter.type) {
          case TOKEN_TYPE_AUTHOR: {
            if (operator === OPERATOR_NOT) {
              filterParams['not[authorUsername]'] = data;
            } else if (operator === OPERATOR_OR) {
              orAuthors.push(data);
            } else {
              filterParams.authorUsername = data;
            }
            break;
          }
          case TOKEN_TYPE_LABEL:
            if (operator === OPERATOR_NOT) {
              notLabels.push(data);
            } else if (operator === OPERATOR_OR) {
              orLabels.push(data);
            } else {
              labels.push(data);
            }
            break;
          case TOKEN_TYPE_MILESTONE:
            filterParams.milestoneTitle = data;
            break;
          case TOKEN_TYPE_CONFIDENTIAL:
            filterParams.confidential = data;
            break;
          case TOKEN_TYPE_MY_REACTION: {
            const key = operator === OPERATOR_NOT ? 'not[myReactionEmoji]' : 'myReactionEmoji';

            filterParams[key] = data;
            break;
          }
          case TOKEN_TYPE_EPIC:
            filterParams.epicIid = data;
            break;
          case TOKEN_TYPE_GROUP:
            filterParams.groupPath = data;
            break;
          case TOKEN_TYPE_SEARCH_WITHIN:
            filterParams.in = data;
            break;
          case FILTERED_SEARCH_TERM:
            if (filter.value.data) {
              filterParams.search = data;
            }
            break;
          default:
            if (this.hasCustomFieldsFeature && this.isCustomField(filter.type)) {
              filterParams[filter.type] = data;
            }
            break;
        }
      });

      if (orAuthors.length) {
        filterParams[`or[authorUsername]`] = orAuthors;
      }

      if (labels.length) {
        filterParams.labelName = labels;
      }

      if (notLabels.length) {
        filterParams[`not[labelName]`] = notLabels;
      }
      if (orLabels.length) {
        filterParams[`or[labelName]`] = orLabels;
      }

      return filterParams;
    },