-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* extensible rule based editing restrictions * can prevent changes to geometry and/or tagging * methods in context for testing restriction rulesets
- Loading branch information
Showing
8 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
iD.restrictions = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
iD.restrictions.ConnectedToHidden = function(context) { | ||
var restriction = { | ||
id: 'connected_to_hidden', | ||
lockGeometry: true, | ||
lockTags: false | ||
}; | ||
|
||
restriction.test = function(ids) { | ||
var graph = context.graph(), | ||
entities = _.map(ids, context.entity), | ||
hasHiddenConnections = function(entity) { | ||
return context.features().hasHiddenConnections(entity, graph); | ||
}; | ||
|
||
if (_.any(entities, hasHiddenConnections)) { | ||
return (ids.length === 1 ? t('restrictions.this_is') : t('restrictions.these_are')) + | ||
' ' + t('restrictions.connected_to_hidden'); | ||
} | ||
return false; | ||
}; | ||
|
||
return restriction; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters