Skip to content

Commit

Permalink
Merge pull request #1869 from geoadmin/gjn_toggle_drawfeedback
Browse files Browse the repository at this point in the history
Revision tool
  • Loading branch information
cedricmoullet committed Nov 25, 2014
2 parents dc532f5 + 93d3aca commit 9e50fca
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 149 deletions.
28 changes: 22 additions & 6 deletions src/components/feedback/FeedbackDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
scope: {
options: '=gaFeedbackOptions',
response: '=gaFeedbackResponse',
map: '=gaFeedbackMap'
map: '=gaFeedbackMap',
active: '=gaFeedbackActive'
},
templateUrl: 'components/feedback/partials/feedback.html',
link: function(scope, element, attrs) {
Expand All @@ -50,8 +51,7 @@
function createFormData() {
var formData,
kml = '';
if (scope.options.attachKML &&
scope.canCreateKml()) {
if (scope.canCreateKml()) {
kml = gaExportKml.create(drawingLayer,
scope.map.getView().getProjection());
}
Expand Down Expand Up @@ -83,8 +83,11 @@
var elFileInpt = element.find('input[type=file]');
scope.isIE9 = (gaBrowserSniffer.msie == 9);
scope.isIE = !isNaN(gaBrowserSniffer.msie);
scope.isMobile = gaBrowserSniffer.mobile;
scope.showProgress = false;
scope.options.attachKML = false;
scope.success = false;
scope.error = false;
scope.form = true;

scope.canCreateKml = function() {
if (!drawingLayer ||
Expand All @@ -95,6 +98,11 @@
return true;
};

scope.activateDraw = function(evt) {
scope.options.activateDrawingDialog();
evt.stopPropagation();
};

if (!scope.isIE || gaBrowserSniffer.msie > 9) {
var triggerInputFileClick = function() {
elFileInpt.click();
Expand Down Expand Up @@ -131,6 +139,12 @@
drawingLayer = data;
});

scope.$watch('active', function(active) {
scope.form = true;
scope.error = false;
scope.success = false;
});

scope.submit = function() {
var contentType;
var formData = createFormData();
Expand All @@ -150,10 +164,12 @@
scope.showProgress = true;
$http(params).success(function(response) {
scope.showProgress = false;
scope.response = 'success';
scope.success = true;
scope.form = false;
}).error(function(response) {
scope.showProgress = false;
scope.response = 'error';
scope.error = true;
scope.form = false;
});

};
Expand Down
88 changes: 50 additions & 38 deletions src/components/feedback/partials/feedback.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
<form ng-submit="submit()">
<label translate>feedback_mail</label>
<input type="email" name="email" ng-model="email">
<label translate>feedback_description</label>
<textarea rows=3 name="feedback" ng-model="feedback" class="form-control" required></textarea>
<p class="help-block">
<span translate>feedback_permalink</span>
<a href="{{permalinkValue}}" target="_blank" translate>permalink</a>
</p>
<p class="help-block">
<span translate>feedback_revision</span>
<a href="http://map.revision.admin.ch" target="_blank" translate>revision_service</a>
</p>
<!-- Draw/kml -->
<div ng-if='canCreateKml()'>
<input type="checkbox" ng-model="options.attachKML"/>
<span translate>attach_drawing_kml</span>
<div>
<div ng-if="success">
<h4 translate>success</h4>
<p translate>feedback_success_message</p>
</div>
<!-- Attachement -->
<div ng-show="!isIE9" class="help-block">
<span translate>feedback_attachment</span>
<div class="input-group-sm">
<!-- The real input -->
<input type="file" name="file" class="ga-feedback-real-file"/>
<!-- The fake input -->
<input class="form-control ga-feedback-fake-file" type="text"
value="{{(file.name) ? file.name + ', ' + file.size/1000 + ' ko' : ''}}"
placeholder="{{'feedback_placeholder' | translate}}" readonly/>
<span class="input-group-btn">
<button type="button" class="btn btn-default ga-feedback-browse-button needsclick">Browse</button>
</span>
<div ng-show="!isIE && showProgress" class="progress progress-striped active">
<div class="progress-bar" style="width: 100%;"></div>
<div ng-if="failure">
<h4 translate>error</h4>
<p translate>feedback_error_message</p>
</div>
<!-- needs to be ng-show, otherwise we break the ng-model -->
<form ng-show="form" ng-submit="submit()">
<label translate>feedback_mail</label>
<input type="email" name="email" ng-model="email">
<label translate>feedback_description</label>
<textarea rows=3 name="feedback" ng-model="feedback" class="form-control" required></textarea>
<!-- permalink -->
<p class="help-block">
<span translate>feedback_permalink</span>
<a href="{{permalinkValue}}" target="_blank" translate> permalink</a>
</p>
<!-- kml-->
<p ng-if="!isMobile && !canCreateKml()" class="help-block">
<span translate>feedback_create_geometry</span>
<a href="" ng-click="activateDraw($event)" translate> draw</a>
</p>
<p ng-if="!isMobile && canCreateKml()" class="help-block">
<span translate>feedback_kml_attached</span>
<a href="" ng-click="activateDraw($event)" translate>feedback_modify_drawing</a>
</p>

<!-- Attachement -->
<div ng-show="!isIE9" class="help-block">
<div class="input-group-sm">
<!-- The real input -->
<input type="file" name="file" class="ga-feedback-real-file"/>
<!-- The fake input -->
<input class="form-control ga-feedback-fake-file" type="text"
value="{{(file.name) ? file.name + ', ' + file.size/1000 + ' ko' : ''}}"
placeholder="{{'feedback_placeholder' | translate}}" readonly/>
<span class="input-group-btn">
<button type="button" class="btn btn-default ga-feedback-browse-button needsclick">Browse</button>
</span>
<div ng-show="!isIE && showProgress" class="progress progress-striped active">
<div class="progress-bar" style="width: 100%;"></div>
</div>
</div>
</div>
</div>
<!-- footer -->
<div class="ga-feedback-footer">
<button type="submit" class="pull-right btn btn-default" translate>send</button>
</div>
</form>
<!-- footer -->
<div class="ga-feedback-footer">
<button type="submit" class="pull-right btn btn-default" translate>send</button>
</div>
</form>
</div>
76 changes: 19 additions & 57 deletions src/index.mako.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
</div>
<div id="toptools">
<div ga-fullscreen ga-fullscreen-map="map"></div>&nbsp;&nbsp;
<a href="#feedback" data-toggle="modal" translate>problem_announcement</a>&nbsp;&nbsp;
<a href="" ng-click="globals.feedbackPopupShown = !globals.feedbackPopupShown">
<span ng-class="{'selected': globals.feedbackPopupShown}" translate>problem_announcement</span>
</a>&nbsp;&nbsp;
<a target="_blank" ng-href="{{topicId + '_help_link_href' | translate}}" translate>help_label</a>&nbsp;&nbsp;
<a ng-href="{{deviceSwitcherHref}}" translate>mobile_redirect</a>&nbsp;&nbsp;
<div ng-controller="GaTranslationController">
Expand Down Expand Up @@ -402,6 +404,11 @@
</a>
<div id="settings" class="collapse">
<div class="panel-body">
<p>
<a href="" ng-click="globals.feedbackPopupShown = !globals.feedbackPopupShown">
<span ng-class="{'selected': globals.feedbackPopupShown}" translate>problem_announcement</span>
</a>
</p>
<p>
<a ng-href="{{deviceSwitcherHref}}" translate>desktop_redirect</a>
</p>
Expand All @@ -417,8 +424,6 @@
</div>
<hr>
<p>
<a href="#feedback" data-toggle="modal" translate>problem_announcement</a>
<br>
<a target="_blank" ng-href="{{topicId + '_service_link_href' | translate}}" ng-cloak translate="{{topicId + '_service_link_label'}}"></a>
<br>
<a target="_blank" ng-href="http://www.geo.admin.ch/internet/geoportal/{{langId}}/home/geoadmin/contact.html#copyright" translate>copyright_label</a>
Expand Down Expand Up @@ -450,62 +455,19 @@
<!-- offline dialog -->
<div ga-offline-menu ga-offline-menu-map="map"></div>
% endif

<!-- feedback dialog -->
<div ng-if="!globals.offline" ng-controller="GaFeedbackController" class="modal-container">
<div id="feedback" class="modal fade" tabindex="-1" role="dialog" ga-modal-show="feedbackModalShown">
<div class="modal-dialog" ga-draggable=".modal-header">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title" translate>problem_announcement</h4>
</div>
<div class="modal-body">
<div ga-feedback
ga-feedback-map="map"
ga-feedback-options="options"
ga-feedback-response="response"></div>
</div>
</div>
</div>
</div>
<div id="feedback-success" class="modal fade" tabindex="-1" role="dialog" ga-modal-show="feedbackSuccessModalShown">
<div class="modal-dialog" ga-draggable=".modal-header">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
</div>
<div class="modal-body">
<h4 translate>success</h4>
<p translate>feedback_success_message</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" translate>close</button>
</div>
</div>
</div>
</div>
<div id="feedback-error" class="modal fade" tabindex="-1" role="dialog" ga-modal-show="feedbackErrorModalShown">
<div class="modal-dialog" ga-draggable=".modal-header">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
</div>
<div class="modal-body">
<h4 translate>error</h4>
<p translate>feedback_error_message</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" translate>close</button>
</div>
</div>
<!-- Popup: Feedback -->
<div ga-popup="globals.feedbackPopupShown"
ga-popup-options="{title:'problem_announcement', help:'671'}"
ga-draggable=".ga-popup-title"
id="feedback-popup" >
<div ng-controller="GaFeedbackController">
<div ga-feedback
ga-feedback-map="map"
ga-feedback-options="options"
ga-feedback-active="globals.feedbackPopupShown">
</div>
</div>
</div>
</div> <!-- end Feedback -->

% if device == 'desktop':
<!-- Popup: Import WMS -->
Expand Down
43 changes: 16 additions & 27 deletions src/js/FeedbackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,24 @@
var module = angular.module('ga_feedback_controller', []);

module.controller('GaFeedbackController',
function($scope, gaGlobalOptions) {
function($scope, $timeout, gaGlobalOptions) {
$scope.options = {
feedbackUrl: gaGlobalOptions.apiUrl + '/feedback'
};

// Feedback success and error modals are hidden by default.
$scope.feedbackSuccessModalShown = false;
$scope.feedbackErrorModalShown = false;

// Hide/show success and error modals when feedback response received.
$scope.$watch('response', function(newVal, oldVal) {
if (newVal) {
var success = $scope.response == 'success';
$scope.feedbackSuccessModalShown = success;
$scope.feedbackErrorModalShown = !success;
$scope.feedbackModalShown = false;
feedbackUrl: gaGlobalOptions.apiUrl + '/feedback',
activateDrawingDialog: function() {
if ($scope.globals.isDrawActive) {
//As a triggered click on the drawing
//popup triggers a digest cycle, we can't
//call it directly or with evalAsync because
//we are in a digest cycle already. Timeout
//to the rescue.
$timeout(function() {
$('#draw-popup h4').click();
}, 0, false);
} else {
$scope.globals.isDrawActive = true;
}
}
});

// We need to reset "response" to undefined when the modals are closed
// by the user. This is to be notified again when the "response" state
// changes again.
$scope.$watch('feedbackSuccessModalShown', function(newVal, oldVal) {
$scope.response = undefined;
});
$scope.$watch('feedbackErrorModalShown', function(newVal, oldVal) {
$scope.response = undefined;
});

};
});

})();
4 changes: 3 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@
"feature": "Objekt",
"featuretree_tooltip": "Suchen Sie alle Objekte in einem Rechteck",
"feedback_attachment": "Datei hinzufügen",
"feedback_create_geometry": "Die haben die Möglichkeit, ihrem Bericht eine Zeichnung anzufügen: ",
"feedback_description": "Ihr Kommentar zum aktuellen Kartenausschnitt",
"feedback_error_message": "Problem beim Versenden der Meldung. ",
"feedback_kml_attached": "Die aktuelle Zeichung wird übermittelt. ",
"feedback_mail": "Ihre E-Mail Adresse (freiwillig)",
"feedback_modify_drawing": "Zeichnung editieren",
"feedback_permalink": "Der folgende Link wird übermittelt: ",
"feedback_placeholder": "Fügen Sie eine .pdf, .zip, .jpg, .jpeg, .kml, .kmz oder .gpx Datei hinzu",
"feedback_revision": "Detaillierte Revisionsmeldung zum Landeskartenwerk:",
Expand Down Expand Up @@ -215,7 +218,6 @@
"reading_file": "Die Datei wird eingelesen...",
"red": "Rot",
"reduce_label": "Verkleinern",
"revision_service": "Revisionsdienst swisstopo",
"sachplan": "Sachpläne",
"sachplan_help_link_href": "http://help.geo.admin.ch/",
"sachplan_service_link_href": "http://www.sachplan.ch",
Expand Down
6 changes: 4 additions & 2 deletions src/locales/empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
"mobile_redirect": "",
"desktop_redirect": "",
"help_label": "",
"revision_service": "",
"link_bowl_crosshair": "",
"bg_chooser_label": "",
"lang_chooser_label": "",
Expand Down Expand Up @@ -278,5 +277,8 @@
"time_all": "",
"time_select_year": "",
"layer_invalid_no_name": "",
"layer_invalid_no_crs": ""
"layer_invalid_no_crs": "",
"feedback_create_geometry": "",
"feedback_kml_attached": "",
"feedback_modify_drawing": ""
}
4 changes: 3 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@
"feature": "Object",
"featuretree_tooltip": "Search for all features inside a rectangle",
"feedback_attachment": "Attach a file",
"feedback_create_geometry": "You have the possibility to attach a drawing to your report: ",
"feedback_description": "Your feedback to the current map extent",
"feedback_error_message": "Problem: Your message could not be sent",
"feedback_kml_attached": "The current drawing will be transferred. ",
"feedback_mail": "Your Email (not mandatory)",
"feedback_modify_drawing": "Modify drawing",
"feedback_permalink": "The following URL will be transferred: ",
"feedback_placeholder": "Attach a pdf, zip, jpg, jpeg, kml, kmz or gpx file",
"feedback_revision": "Reporting a detailed revision regarding the national map:",
Expand Down Expand Up @@ -215,7 +218,6 @@
"reading_file": "Reading file...",
"red": "red",
"reduce_label": "Minimize",
"revision_service": "revision service of swisstopo",
"sachplan": "Sectoral plans",
"sachplan_help_link_href": "http://help.geo.admin.ch/?lang=en",
"sachplan_service_link_href": "http://www.sachplan.ch",
Expand Down
Loading

0 comments on commit 9e50fca

Please sign in to comment.