Skip to content
This repository has been archived by the owner on Aug 8, 2021. It is now read-only.

Commit

Permalink
Fix ticket search form to enable searching by keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
ujiro99 committed Jun 6, 2017
1 parent b72d362 commit 50f452d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 21 deletions.
13 changes: 8 additions & 5 deletions src/coffee/controllers/timerCtrl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ timeTracker.controller 'TimerCtrl', ($scope, $timeout, Redmine, Project, Ticket,
$scope.typeaheadOptions = { highlight: true, minLength: 0 }
# jquery-timepicker options
$scope.timePickerOptions = null
# keyword which inputted on search form.
$scope.searchKeyword = null
# mode state objects
auto = pomodoro = manual = null
# Application options
Expand All @@ -45,6 +47,7 @@ timeTracker.controller 'TimerCtrl', ($scope, $timeout, Redmine, Project, Ticket,
pomodoro = new Pomodoro()
manual = new Manual()
$scope.mode = auto
$scope.word = DataAdapter.searchKeyword
Option.onChanged('stepTime', initializePicker)


Expand Down Expand Up @@ -114,12 +117,12 @@ timeTracker.controller 'TimerCtrl', ($scope, $timeout, Redmine, Project, Ticket,
Workaround for restore selected state on switching view.
###
restoreSelected = () ->
return if not DataAdapter.selectedTicket
tmpTicket = DataAdapter.selectedTicket
tmpActivity = DataAdapter.selectedActivity
return if not DataAdapter.searchKeyword.ticket
tmpTicket = DataAdapter.searchKeyword.ticket
tmpActivity = DataAdapter.searchKeyword.activity
$timeout () ->
DataAdapter.selectedTicket = tmpTicket
DataAdapter.selectedActivity = tmpActivity
DataAdapter.searchKeyword.ticket = tmpTicket
DataAdapter.searchKeyword.activity = tmpActivity
, SWITCHING_TIME / 2


Expand Down
44 changes: 40 additions & 4 deletions src/coffee/services/dataAdapter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L

###*
# @property account
# @type AccountModel
# @type {AccountModel}
###
@account = {}

Expand Down Expand Up @@ -49,6 +49,38 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L
@statuses = []


###*
Class representing the search word entered.
@class SearchKeyword
###
class SearchKeyword

constructor: (@data) ->

###*
Selected Ticket Model or inputted search word.
@type {TicketModel|String}
###
_ticket: null
@property 'ticket',
get: -> return @_ticket
set: (val) ->
@_ticket = val
if val is null or !!val.id # not String
@data.selectedTicket = val

###*
Selected Activity Model or inputted search word.
@type {ActivityModel|String}
###
_activity: null
@property 'activity',
get: -> return @_activity
set: (val) ->
@_activity = val
if val is null or !!val.id
@data.selectedActivity = val

###*
Adapter class for GUI and data models.
@class DataAdapter
Expand All @@ -72,6 +104,7 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L
# @constructor
###
constructor: () ->
@searchKeyword = new SearchKeyword(@)
@_bindDataModelGetter()
Option.onChanged "isProjectStarEnable", () =>
@_updateStarredProjects()
Expand Down Expand Up @@ -157,8 +190,9 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L
set: (n) ->
return if @_selectedTicket is n
@_selectedTicket = n
@searchKeyword._ticket = n
@_activities.set @_data[n.url].activities if n and @_data[n.url]
@_selectedActivity = @_activities[0]
@selectedActivity = @_activities[0]
@fireEvent(@SELECTED_TICKET_CHANGED, @, n)
Log.debug("selectedTicket set: " + n?.text)
Log.debug("selectedActivity set: " + @_selectedActivity?.name)
Expand All @@ -167,7 +201,9 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L
_selectedActivity: null
@property 'selectedActivity',
get: -> @_selectedActivity
set: (n) -> @_selectedActivity = n
set: (n) ->
@_selectedActivity = n
@searchKeyword._activity = n

# selected query.
_selectedQuery: null
Expand Down Expand Up @@ -345,7 +381,7 @@ timeTracker.factory("DataAdapter", (Analytics, EventDispatcher, Const, Option, L
@_data[url].activities = activities
if @selectedTicket and @selectedTicket.url is url
@_activities.set activities
@_selectedActivity = activities[0]
@selectedActivity = activities[0]
Log.debug("setActivities: #{url}")

###*
Expand Down
8 changes: 4 additions & 4 deletions src/jade/_auto.jade
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="ticketData"
ng-model="data.selectedTicket"
ng-click="data.selectedTicket = null"
ng-model="word.ticket"
ng-click="word.ticket = null"
placeholder='Select issue...')
i.fa.fa-angle-down

Expand All @@ -38,8 +38,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="activityData"
ng-model="data.selectedActivity"
ng-click="data.selectedActivity = null"
ng-model="word.activity"
ng-click="word.activity = null"
placeholder='Select activity...')
i.fa.fa-angle-down

Expand Down
8 changes: 4 additions & 4 deletions src/jade/_manual.jade
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="ticketData"
ng-model="data.selectedTicket"
ng-click="data.selectedTicket = null"
ng-model="word.ticket"
ng-click="word.ticket = null"
placeholder='Select issue...')
i.fa.fa-angle-down

Expand All @@ -30,8 +30,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="activityData"
ng-model="data.selectedActivity"
ng-click="data.selectedActivity = null"
ng-model="word.activity"
ng-click="word.activity = null"
placeholder='Select activity...')
i.fa.fa-angle-down

Expand Down
8 changes: 4 additions & 4 deletions src/jade/_pomodoro.jade
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="ticketData"
ng-model="data.selectedTicket"
ng-click="data.selectedTicket = null"
ng-model="word.ticket"
ng-click="word.ticket = null"
placeholder='Select issue...')
i.fa.fa-angle-down

Expand All @@ -40,8 +40,8 @@ form(action='#', method='POST', name='time_entry')
input.sfTypeahead.form-control.input-sm(type="text"
options="typeaheadOptions"
datasets="activityData"
ng-model="data.selectedActivity"
ng-click="data.selectedActivity = null"
ng-model="word.activity"
ng-click="word.activity = null"
placeholder='Select activity...')
i.fa.fa-angle-down

Expand Down

0 comments on commit 50f452d

Please sign in to comment.