diff --git a/src/scripts/controllers/dapiControllers.coffee b/src/scripts/controllers/dapiControllers.coffee index 780de551..1f279354 100644 --- a/src/scripts/controllers/dapiControllers.coffee +++ b/src/scripts/controllers/dapiControllers.coffee @@ -408,17 +408,38 @@ class VehicleDetailController extends DetailController super(data) +class MissionSupportController + @$inject: ['$log', '$scope', 'mission', 'user', 'missionService'] + constructor: (@log, @scope, @mission, @user, @service) -> + @log.info 'hello this is modals reporting!' + @scope.mission = @mission + @scope.user = @user + @scope.extraInfo = '' + + send_support_ticket: (form = {$dirty: false}) => + ticketPayload = {priority: 'unused'} + if form.$dirty + ticketPayload.extraInfo = form.extraInfo.$viewValue + @service.openSupportTicket(@mission, ticketPayload).then (response) => + @scope.$dismiss('cancel') + class MissionDetailController extends DetailController - @$inject: ['$modal', '$log', '$scope', '$routeParams', 'missionService', '$rootScope', 'authService', '$window', '$sce', 'ngProgressLite'] - constructor: (@modal, @log, scope, routeParams, @service, @rootScope, @authService, window, @sce, ngProgressLite) -> - scope.$on 'loading-started', (event, config) -> ngProgressLite.start() if event.currentScope.urlBase == config.url - scope.$on 'loading-complete', (event, config) -> ngProgressLite.done() if event.currentScope.urlBase == config.url + @$inject: ['$modal', '$log', '$scope', '$routeParams', 'preFetchedMission', 'missionService', '$rootScope', 'authService', '$window', '$sce', 'ngProgressLite'] + constructor: (@modal, @log, @scope, routeParams, @record, @service, @rootScope, @authService, window, @sce, ngProgressLite) -> + @scope.$on 'loading-started', (event, config) -> ngProgressLite.start() if event.currentScope.urlBase == config.url + @scope.$on 'loading-complete', (event, config) -> ngProgressLite.done() if event.currentScope.urlBase == config.url - super(scope, routeParams, window) - @scope.urlBase = @urlBase # FIXME - is there a better way to pass this out to the html? + super(@scope, routeParams, window, false) + + # make sure we call this since its the function that + # fixes the record and sets up open graph tags + @handle_fetch_response(@record) + + @scope.urlBase = @urlBase @scope.center = {} @scope.bounds = {} @scope.geojson = {} + @scope.record = @record @service.get_geojson(@routeParams.id).then (result) => @log.debug("Setting geojson") @@ -469,6 +490,18 @@ class MissionDetailController extends DetailController name = 'doarama' + @record.id @window.open(@scope.doaramaURL, name, "width=940,height=420,scrollbars=no,left=#{x},top=#{y}") + @get_support_modal = () => + @log.info('creating window dialog for support tickets') + dialog = @modal.open + templateUrl: '/views/mission/support-ticket.html' + controller: 'missionSupportController as controller' + resolve: + mission: => + @record + user: ['$route', 'userService', ($route, userService) => + userService.getId(@record.userName) + ] + # Subclasses can override if they would like to strip content out before submitting get_record_for_submit: => # The server doesn't understand this yet @@ -482,10 +515,10 @@ class MissionDetailController extends DetailController # We update open social data so facebook shows nice content handle_fetch_response: (data) => - super(data) - # FIXME - unify these fixups with the regular mission record fetch - should be in the service instead! - fixupMission(data, @authService.getUser()) + @record = fixupMission(data, @authService.getUser()) + + super(data) if !data.latitude? @set_error('This mission did not include location data') @@ -549,6 +582,7 @@ class MissionAnalysisController extends BaseController angular.module('app').controller 'userDetailController', UserDetailController angular.module('app').controller 'vehicleDetailController', VehicleDetailController angular.module('app').controller 'missionDetailController', MissionDetailController +angular.module('app').controller 'missionSupportController', MissionSupportController angular.module('app').controller 'missionParameterController', MissionParameterController angular.module('app').controller 'missionPlotController', MissionPlotController angular.module('app').controller 'missionAnalysisController', MissionAnalysisController diff --git a/src/scripts/routes.coffee b/src/scripts/routes.coffee index 6597d590..e0162b61 100644 --- a/src/scripts/routes.coffee +++ b/src/scripts/routes.coffee @@ -45,6 +45,10 @@ class Config controller: 'missionDetailController as controller' title: 'Detail' templateUrl: '/views/mission/detail-window.html' + resolve: + preFetchedMission: ['$route', 'missionService', ($route, missionService) -> + missionService.getId($route.current.params.id) + ] .when '/parameters/:id', templateUrl: '/views/mission/parameters-window.html' .when '/analysis/:id', diff --git a/src/scripts/services/dapiServices.coffee b/src/scripts/services/dapiServices.coffee index f3f9e986..e86c170c 100644 --- a/src/scripts/services/dapiServices.coffee +++ b/src/scripts/services/dapiServices.coffee @@ -225,6 +225,10 @@ class MissionService extends RESTService endpoint: "mission" + openSupportTicket: (mission, ticketPayload) => + @log.debug "Posting new Ticket" + @postId("#{mission.id}/openTicket", ticketPayload) + getAllMissions: (fetchParams) => fetchParams or= @getFetchParams() @getMissionsFromParams(fetchParams) diff --git a/src/views/mission/detail-window.html b/src/views/mission/detail-window.html index ad05cda1..6d64acf0 100644 --- a/src/views/mission/detail-window.html +++ b/src/views/mission/detail-window.html @@ -132,6 +132,15 @@