Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #84: Change feature count tracking to operate across AI source types #85

Merged
merged 4 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ en:
description: Does this look like an accurate feature? Select this to start editing it so that you can connect, tag, and save it to OpenStreetMap. 👍
annotation: Added a Map With AI feature.
tooltip: Add this feature to the map to begin editing.
disabled: To help improve OSM data quality, we only allow {n} ML roads to be added in each mapping session. Please try to fix issues on your edits so far. You will be able to add more roads after saving.
disabled_flash: To help improve OSM data quality, we only allow {n} ML roads to be added in each mapping session.
disabled: To help improve OSM data quality, we only allow {n} AI features to be added in each mapping session. Please try to fix issues on your edits so far. You will be able to add more AI features after saving.
disabled_flash: To help improve OSM data quality, we only allow {n} AI Features to be added in each mapping session.
key: A
option_reject:
label: Remove This Feature
Expand Down
11 changes: 11 additions & 0 deletions modules/core/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export function coreHistory(context) {
},


countAIFeaturesAdded: function() {
var count = 0;
for (var i = 0; i <= _index; i++) {
if (_stack[i].annotation && _stack[i].annotation.type === 'fb_accept_feature') {
count++;
}
}
return count;
},


peekAllAnnotations: function() {
var result = [];
for (var i = 0; i <= _index; i++) {
Expand Down
25 changes: 9 additions & 16 deletions modules/ui/fb_feature_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,29 @@ import { uiRapidFirstEdit } from './rapid_first_edit_dialog';

export function uiFbFeaturePicker(context, keybinding) {
var _datum;
var ML_ROADS_LIMIT_NON_TM_MODE = 50;
var AI_FEATURES_LIMIT_NON_TM_MODE = 50;


function isAddRoadDisabled() {
function isAddFeatureDisabled() {
// when task GPX is set in URL (TM mode), "add roads" is always enabled
var gpxInUrl = utilStringQs(window.location.hash).gpx;
if (gpxInUrl) return false;

var mlRoadsCount = 0;
var entities = context.graph().entities;
for (var eid in entities) {
var e = entities[eid];
if (eid.startsWith('w-') && e && (e.tags.source === 'digitalglobe' || e.tags.source === 'maxar')) {
mlRoadsCount += 1;
}
}
return mlRoadsCount >= ML_ROADS_LIMIT_NON_TM_MODE;
var numAiFeatures = context.history().countAIFeaturesAdded();
Bonkles marked this conversation as resolved.
Show resolved Hide resolved
return numAiFeatures >= AI_FEATURES_LIMIT_NON_TM_MODE;
}


function onAcceptRoad() {
if (_datum) {
if (isAddRoadDisabled()) {
if (isAddFeatureDisabled()) {
var flash = uiFlash()
.duration(4000)
.iconName('#iD-icon-rapid-plus-circle')
.iconClass('operation disabled')
.text(t(
'fb_feature_picker.option_accept.disabled_flash',
{n: ML_ROADS_LIMIT_NON_TM_MODE}
{n: AI_FEATURES_LIMIT_NON_TM_MODE}
));
flash();
return;
Expand Down Expand Up @@ -204,18 +197,18 @@ export function uiFbFeaturePicker(context, keybinding) {
.placement('bottom')
.html(true)
.title(function() {
return isAddRoadDisabled()
return isAddFeatureDisabled()
? uiTooltipHtml(t(
'fb_feature_picker.option_accept.disabled',
{n: ML_ROADS_LIMIT_NON_TM_MODE}
{n: AI_FEATURES_LIMIT_NON_TM_MODE}
))
: uiTooltipHtml(
t('fb_feature_picker.option_accept.tooltip'),
t('fb_feature_picker.option_accept.key')
);
}),
onClick: onAcceptRoad,
disabledFunction: isAddRoadDisabled
disabledFunction: isAddFeatureDisabled
}, 'ai-features-accept');

presetItem(bodyEnter, {
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/rapid_feature_toggle_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function uiRapidFeatureToggleDialog(context, AIFeatureToggleKey, featureT
toggleOptionText
.append('div')
.attr('class', 'rapid-feature-license')
.html(options.license)
.html(options.license);

toggleOptionText.select('p a')
.attr('target','_blank');
Expand Down