superdesk/superdesk-client-core

View on GitHub
scripts/apps/ingest/views/settings/service-config.html

Summary

Maintainability
Test Coverage
<div class="form__row form__row--s-padding" ng-repeat="field in currentFeedingService.fields track by field.id">
    <div class="sd-line-input" ng-if="field.type === 'text'" ng-show="isConfigFieldVisible(field)">
        <label class="sd-line-input__label" for="{{getConfigFieldId(field.id)}}">{{field.label | translate}}</label>
        <input class="sd-line-input__input" type="{{field.type}}" id="{{getConfigFieldId(field.id)}}" placeholder="{{:: field.placeholder | translate}}"
            ng-model="provider.config[field.id]" ng-required="isConfigFieldRequired(field)" ng-readonly="field.readonly === true" ng-change="$parent.setConfig(provider)"
            ng-show="isConfigFieldVisible(field)">
        <div sd-ingest-config-errors></div>
    </div>

    <div class="sd-line-input" ng-if="field.type === 'password'" ng-show="isConfigFieldVisible(field)">
        <label class="sd-line-input__label" for="{{getConfigFieldId(field.id)}}">{{field.label | translate}}</label>
        <input class="sd-line-input__input" type="password" id="{{getConfigFieldId(field.id)}}" placeholder="{{:: field.placeholder | translate}}"
            ng-model="provider.config[field.id]" ng-required="isConfigFieldRequired(field)" ng-readonly="field.readonly === true" ng-change="$parent.setConfig(provider)"
            ng-show="isConfigFieldVisible(field)" autocomplete="new-password">
        <div sd-ingest-config-errors></div>
    </div>

    <div class="form__row" ng-if="field.type === 'boolean'" ng-show="isConfigFieldVisible(field)">
        <span sd-switch id="{{getConfigFieldId(field.id)}}" ng-model="provider.config[field.id]"
        ng-required="isConfigFieldRequired(field)" ng-readonly="field.readonly === true"></span>
        <label for="{{getConfigFieldId(field.id)}}">{{field.label | translate}}</label>
        <div sd-ingest-config-errors></div>
    </div>

    <div class="form__row" ng-if="field.type === 'url_request'" ng-show="isConfigFieldVisible(field)">
        <button
            type="button"
            class="btn btn--primary"
            ng-click="doUrlRequest(provider, field, editForm.$dirty)">
            {{field.label}}
        </button>
    </div>


    <div class="sd-line-input sd-line-input--is-select" ng-if="field.type === 'choices'" ng-show="isConfigFieldVisible(field)">
        <label class="sd-line-input__label" for="{{getConfigFieldId(field.id)}}">{{field.label | translate}}</label>
        <select id="{{getConfigFieldId(field.id)}}"
                class="sd-line-input__select"
                ng-required="isConfigFieldRequired(field)"
                ng-readonly="field.readonly === true"
                ng-options="r[0] as r[1] for r in field.choices"
                ng-model="provider.config[field.id]">
        </select>
    </div>

    <fieldset class="separated rss-config" ng-if="field.type === 'mapping'">
      <legend translate>{{field.label | translate}}</legend>

      <div class="sd-alert sd-alert--hollow sd-alert--small sd-alert--no-margin" ng-show="provider.config[field.id].length == 0" ng-hide="fieldAliases[field.id].length > 0">
        {{:: field.empty_label|translate }}
      </div>

      <div class="form__row form__row--flex form__row--s-padding" ng-show="fieldAliases[field.id].length > 0">
        <div class="sd-line-input sd-line-input--no-margin" style="max-width: 276px;">
          <label class="sd-line-input__label">{{ field.first_field_options.label|translate}}</label>
        </div>
        <div class="sd-line-input sd-line-input--no-margin">
            <label class="sd-line-input__label">{{ field.second_field_options.label|translate}}</label>
        </div>
      </div>

      <div class="form__row form__row--flex form__row--s-padding" ng-repeat="item in fieldAliases[field.id]">
        <div class="sd-line-input sd-line-input--is-select sd-line-input--boxed sd-line-input--no-margin sd-line-input--no-label">
          <select class="sd-line-input__select"
                  ng-options="fieldName for fieldName in (availableFieldOptions(field.id, item.fieldName) | orderBy)"
                  ng-model="item.fieldName"
                  ng-change="fieldSelectionChanged(field)">
          </select>
        </div>
        <div class="sd-line-input sd-line-input--boxed sd-line-input--no-margin  sd-line-input--no-label">
            <input class="sd-line-input__input" type="text"
                  placeholder="{{:: field.second_field_options.placeholder|translate }}"
                  ng-model="item.alias">
        </div>
        <button style="margin-left: 8px;"
            type="button"
            class="icn-btn"
            ng-click="removeFieldAlias(field.id, $index)"
            tooltip="{{:: field.remove_mapping_label|translate}}"
            tooltip-placement="bottom"
            tooltip-popup-delay="500">
          <i class="icon-trash"></i>
        </button>
      </div>

      <div class="form__row form__row--inner" ng-show="!fieldAliases[field.id] || fieldAliases[field.id].length < field.first_field_options.values.length" style="text-align: end;">
        <button
            type="button"
            class="btn btn--primary btn--hollow"
            ng-click="addFieldAlias(field.id)">
          <i class="icon-plus-sign"></i> {{:: field.add_mapping_label|translate}}
        </button>
      </div>

    </fieldset>
</div>