Skip to content

Commit

Permalink
display count of placeholder items in multiple items setting in new t…
Browse files Browse the repository at this point in the history
…ask page
  • Loading branch information
mayswind committed May 8, 2023
1 parent 89ec302 commit b23ad16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/scripts/directives/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
link: function (scope, element, attrs, ngModel) {
var pendingSaveRequest = null;
var options = {
showPlaceholderCount: false,
deleteKeyAlwaysChangeValue: false,
lazySaveTimeout: ariaNgConstants.lazySaveTimeout,
errorTooltipPlacement: 'top',
Expand Down Expand Up @@ -85,7 +86,7 @@
};

var getTotalCount = function (itemsText, separator, trim) {
if (!itemsText || !angular.isString(itemsText)) {
if (!itemsText || !separator || !angular.isString(itemsText)) {
return 0;
}

Expand Down Expand Up @@ -180,6 +181,10 @@
var fixedValueCount = getTotalCount(scope.fixedValue, scope.option.separator, scope.option.trimCount);
var inputValueCount = getTotalCount(scope.optionValue, scope.option.separator, scope.option.trimCount);

if (!scope.optionValue && scope.showPlaceholderCount) {
inputValueCount = scope.placeholderItemCount;
}

return fixedValueCount + inputValueCount;
};

Expand Down Expand Up @@ -313,8 +318,10 @@
}

scope.placeholder = getHumanReadableValue(displayValue);
scope.placeholderItemCount = getTotalCount(scope.placeholder, scope.option.separator, scope.option.trimCount);
});

scope.showPlaceholderCount = options.showPlaceholderCount === true || options.showPlaceholderCount === 'true';
loadHistory();
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/views/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
</div>
</div>
<ng-setting ng-repeat="option in context.availableOptions" ng-if="context.optionFilter[option.category]"
option="option" lazy-save-timeout="0" delete-key-always-change-value="true"
option="option" show-placeholder-count="true"
lazy-save-timeout="0" delete-key-always-change-value="true"
default-value="(option.overrideMode !== 'append' && !context.options[option.key] && context.options[option.key] !== '') ? context.globalOptions[option.key] : ''"
fixed-value="option.overrideMode === 'append' ? context.globalOptions[option.key] : ''"
on-change-value="setOption(key, value, optionStatus)"></ng-setting>
Expand Down
2 changes: 1 addition & 1 deletion src/views/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<em ng-bind="'(' + option.key + ')'"></em>
<i class="icon-primary fa fa-question-circle" ng-if="(option.descriptionKey | translate) !== ''"
data-toggle="popover" data-trigger="hover" data-placement="auto top" data-container="body" data-content="{{option.descriptionKey | translate}}"></i>
<span class="description" ng-if="option.showCount && option.separator && (optionValue || fixedValue)"
<span class="description" ng-if="option.showCount && option.separator && (optionValue || fixedValue || (placeholder && showPlaceholderCount))"
ng-bind="'format.settings.total-count' | translate: {count: getTotalCount()}"></span>
<i class="icon-primary fa fa-info-circle" ng-if="(option.since && option.since !== '')" ng-tooltip="{{('format.requires.aria2-version' | translate: {version: option.since})}}" ng-tooltip-container="body" ng-tooltip-placement="right"></i>
</div>
Expand Down

0 comments on commit b23ad16

Please sign in to comment.