Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented issue #373 - Feature "Time recording”.
- Loading branch information
Showing
20 changed files
with
685 additions
and
10 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
20 changes: 20 additions & 0 deletions
20
app/assets/javascripts/app/controllers/ticket_zoom/time_accounting.coffee
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,20 @@ | ||
class App.TicketZoomTimeAccounting extends App.ControllerModal | ||
buttonClose: true | ||
buttonCancel: 'skip' | ||
buttonSubmit: 'Account Time' | ||
buttonClass: 'btn--success' | ||
head: 'Time Accounting' | ||
small: true | ||
|
||
content: -> | ||
App.view('ticket_zoom/time_accounting')() | ||
|
||
onCancel: => | ||
if @cancelCallback | ||
@cancelCallback() | ||
|
||
onSubmit: => | ||
@close() | ||
if @submitCallback | ||
params = @formParams() | ||
@submitCallback(params) |
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/app/controllers/ticket_zoom/time_unit.coffee
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,11 @@ | ||
class App.TicketZoomTimeUnit extends App.ObserverController | ||
model: 'Ticket' | ||
observe: | ||
time_unit: true | ||
|
||
render: (ticket) => | ||
return if !@permissionCheck('ticket.agent') | ||
return if !ticket.time_unit | ||
@html App.view('ticket_zoom/time_unit')( | ||
ticket: ticket | ||
) |
205 changes: 205 additions & 0 deletions
205
app/assets/javascripts/app/controllers/time_accounting.coffee
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,205 @@ | ||
class Index extends App.ControllerSubContent | ||
requiredPermission: 'admin.time_accounting' | ||
header: 'Time Accounting' | ||
events: | ||
'change .js-timeAccountingSetting input': 'setTimeAccounting' | ||
'click .js-timePickerYear': 'setYear' | ||
'click .js-timePickerMonth': 'setMonth' | ||
|
||
elements: | ||
'.js-timeAccountingSetting input': 'timeAccountingSetting' | ||
|
||
constructor: -> | ||
super | ||
|
||
current = new Date() | ||
currentDay = current.getDate() | ||
currentMonth = current.getMonth() + 1 | ||
currentYear = current.getFullYear() | ||
currentWeek = current.getWeek() | ||
if !@month | ||
@month = currentMonth | ||
if !@year | ||
@year = currentYear | ||
|
||
@subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) | ||
|
||
release: => | ||
App.Setting.unsubscribe(@subscribeId) | ||
|
||
render: => | ||
currentNewTagSetting = @Config.get('time_accounting') || false | ||
#return if currentNewTagSetting is @lastNewTagSetting | ||
@lastNewTagSetting = currentNewTagSetting | ||
|
||
timeRangeYear = [] | ||
year = new Date().getFullYear() | ||
for item in [year-2..year] | ||
record = { | ||
display: item | ||
value: item | ||
} | ||
timeRangeYear.push record | ||
|
||
timeRangeMonth = [ | ||
{ | ||
display: 'Jan' | ||
value: 1 | ||
}, | ||
{ | ||
display: 'Feb' | ||
value: 2 | ||
}, | ||
{ | ||
display: 'Mar' | ||
value: 3 | ||
}, | ||
{ | ||
display: 'Apr' | ||
value: 4, | ||
}, | ||
{ | ||
display: 'Mai' | ||
value: 5, | ||
}, | ||
{ | ||
display: 'Jun' | ||
value: 6, | ||
}, | ||
{ | ||
display: 'Jul' | ||
value: 7, | ||
}, | ||
{ | ||
display: 'Aug' | ||
value: 8, | ||
}, | ||
{ | ||
display: 'Sep' | ||
value: 9, | ||
}, | ||
{ | ||
display: 'Oct' | ||
value: 10, | ||
}, | ||
{ | ||
display: 'Nov' | ||
value: 11, | ||
}, | ||
{ | ||
display: 'Dec' | ||
value: 12, | ||
}, | ||
] | ||
|
||
@html App.view('time_accounting/index')( | ||
timeRangeYear: timeRangeYear | ||
timeRangeMonth: timeRangeMonth | ||
year: @year | ||
month: @month | ||
) | ||
|
||
configure_attributes = [ | ||
{ name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: false, preview: false, action: false, hasChanged: false }, | ||
] | ||
|
||
new App.ControllerForm( | ||
el: @$('.js-selector') | ||
model: | ||
configure_attributes: configure_attributes, | ||
autofocus: true | ||
) | ||
|
||
new ByTicket( | ||
el: @$('.js-tableTicket') | ||
year: @year | ||
month: @month | ||
) | ||
|
||
new ByCustomer( | ||
el: @$('.js-tableCustomer') | ||
year: @year | ||
month: @month | ||
) | ||
|
||
new ByOrganization( | ||
el: @$('.js-tableOrganization') | ||
year: @year | ||
month: @month | ||
) | ||
|
||
setTimeAccounting: (e) => | ||
value = @timeAccountingSetting.prop('checked') | ||
App.Setting.set('time_accounting', value) | ||
|
||
setYear: (e) => | ||
e.preventDefault() | ||
@year = $(e.target).data('type') | ||
@render() | ||
|
||
setMonth: (e) => | ||
e.preventDefault() | ||
@month = $(e.target).data('type') | ||
@render() | ||
|
||
class ByTicket extends App.Controller | ||
constructor: -> | ||
super | ||
@load() | ||
|
||
load: => | ||
@ajax( | ||
id: 'by_ticket' | ||
type: 'GET' | ||
url: "#{@apiPath}/time_accounting/log/by_ticket/#{@year}/#{@month}" | ||
processData: true | ||
success: (data, status, xhr) => | ||
@render(data) | ||
) | ||
|
||
render: (rows) => | ||
@html App.view('time_accounting/by_ticket')( | ||
rows: rows | ||
) | ||
|
||
class ByCustomer extends App.Controller | ||
constructor: -> | ||
super | ||
@load() | ||
|
||
load: => | ||
@ajax( | ||
id: 'by_customer' | ||
type: 'GET' | ||
url: "#{@apiPath}/time_accounting/log/by_customer/#{@year}/#{@month}" | ||
processData: true | ||
success: (data, status, xhr) => | ||
@render(data) | ||
) | ||
|
||
render: (rows) => | ||
@html App.view('time_accounting/by_customer')( | ||
rows: rows | ||
) | ||
|
||
class ByOrganization extends App.Controller | ||
constructor: -> | ||
super | ||
@load() | ||
|
||
load: => | ||
@ajax( | ||
id: 'by_organization' | ||
type: 'GET' | ||
url: "#{@apiPath}/time_accounting/log/by_organization/#{@year}/#{@month}" | ||
processData: true | ||
success: (data, status, xhr) => | ||
@render(data) | ||
) | ||
|
||
render: (rows) => | ||
@html App.view('time_accounting/by_organization')( | ||
rows: rows | ||
) | ||
|
||
App.Config.set('TimeAccounting', { prio: 8500, name: 'Time Accounting', parent: '#manage', target: '#manage/time_accounting', controller: Index, permission: ['admin.time_accounting'] }, 'NavBarAdmin') |
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
6 changes: 6 additions & 0 deletions
6
app/assets/javascripts/app/views/ticket_zoom/sidebar_ticket.jst.eco
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,6 @@ | ||
<form> | ||
<fieldset class="edit"></fieldset> | ||
</form> | ||
<div class="tags"></div> | ||
<div class="links"></div> | ||
<div class="js-timeUnit"></div> |
3 changes: 3 additions & 0 deletions
3
app/assets/javascripts/app/views/ticket_zoom/time_accounting.jst.eco
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,3 @@ | ||
<form> | ||
<input type="text" name="time_unit" placeholder="<%- @T('Please enter your time which you want to account.') %>"/> | ||
</form> |
4 changes: 4 additions & 0 deletions
4
app/assets/javascripts/app/views/ticket_zoom/time_unit.jst.eco
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,4 @@ | ||
<div> | ||
<label><%- @T('Accounted Time') %></label> | ||
<div><%= @ticket.time_unit %></div> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
app/assets/javascripts/app/views/time_accounting/by_customer.jst.eco
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 @@ | ||
<% if !@rows.length: %> | ||
<table class="settings-list settings-list--stretch settings-list--placeholder"> | ||
<thead><tr><th><%- @T('No Entries') %> | ||
</table> | ||
<% else: %> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<tr> | ||
<th><%- @T('Customer') %> | ||
<th><%- @T('Organization') %> | ||
<th><%- @T('Time Units') %> | ||
</thead> | ||
<tbody> | ||
<% for row in @rows: %> | ||
<tr> | ||
<td><a href="#user/profile/<%- row.customer.id %>"><%= row.customer.email %></a> | ||
<td><% if row.organization: %><%= row.organization.name %><% end %> | ||
<td><%= row.time_unit %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<% end %> |
21 changes: 21 additions & 0 deletions
21
app/assets/javascripts/app/views/time_accounting/by_organization.jst.eco
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,21 @@ | ||
<% if !@rows.length: %> | ||
<table class="settings-list settings-list--stretch settings-list--placeholder"> | ||
<thead><tr><th><%- @T('No Entries') %> | ||
</table> | ||
<% else: %> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<tr> | ||
<th><%- @T('Organization') %> | ||
<th><%- @T('Time Units') %> | ||
</thead> | ||
<tbody> | ||
<% for row in @rows: %> | ||
<tr> | ||
<td><a href="#organization/profile/<%- row.organization.id %>"><%= row.organization.name %></a> | ||
<td><%= row.time_unit %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<% end %> |
Oops, something went wrong.