1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-24 17:04:32 +03:00
parent 6331f44054
commit a639ff49f0
3 changed files with 27 additions and 22 deletions

View File

@ -17,7 +17,7 @@ class TaskRequest extends EntityRequest
if ($this->project_id == '-1') { if ($this->project_id == '-1') {
$project = [ $project = [
'name' => trim($this->project_name), 'name' => trim($this->project_name),
'client_id' => Client::getPrivateId($this->client), 'client_id' => Client::getPrivateId($this->client_id ?: $this->client),
]; ];
if (Project::validate($project) === true) { if (Project::validate($project) === true) {
$project = app('App\Ninja\Repositories\ProjectRepository')->save($project); $project = app('App\Ninja\Repositories\ProjectRepository')->save($project);

View File

@ -84,7 +84,7 @@
<!-- Navbar Filter --> <!-- Navbar Filter -->
<div class="input-group input-group-lg"> <div class="input-group input-group-lg">
<span class="input-group-addon" style="width:1%;" title="{{ trans('texts.filter_sort') }}"><span class="glyphicon glyphicon-filter"></span></span> <span class="input-group-addon" style="width:1%;" title="{{ trans('texts.filter_sort') }}"><span class="glyphicon glyphicon-filter"></span></span>
<input type="search" class="form-control search" autocomplete="off" autofocus="autofocus" <input id="search" type="search" class="form-control search" autocomplete="off" autofocus="autofocus"
data-bind="event: { focus: onFilterFocus, input: onFilterChanged, keypress: onFilterKeyPress }, value: filter, valueUpdate: 'afterkeydown', attr: {placeholder: placeholder}"> data-bind="event: { focus: onFilterFocus, input: onFilterChanged, keypress: onFilterKeyPress }, value: filter, valueUpdate: 'afterkeydown', attr: {placeholder: placeholder}">
<span class="input-group-addon" style="width:1%;" title="{{ trans('texts.refresh') }}"><span class="glyphicon glyphicon-repeat"></span></span> <span class="input-group-addon" style="width:1%;" title="{{ trans('texts.refresh') }}"><span class="glyphicon glyphicon-repeat"></span></span>
</div> </div>
@ -209,7 +209,6 @@
var clientMap = {}; var clientMap = {};
var projectMap = {}; var projectMap = {};
var projectsForClientMap = {}; var projectsForClientMap = {};
var projectsForAllClients = [];
function refreshProjectList(forceClear) { function refreshProjectList(forceClear) {
var clientId = $('input[name=client_id]').val(); var clientId = $('input[name=client_id]').val();
@ -222,7 +221,7 @@
} }
@endif @endif
var list = (clientId && ! forceClear) ? (projectsForClientMap.hasOwnProperty(clientId) ? projectsForClientMap[clientId] : []).concat(projectsForAllClients) : projects; var list = (clientId && ! forceClear) ? (projectsForClientMap.hasOwnProperty(clientId) ? projectsForClientMap[clientId] : []) : projects;
for (var i=0; i<list.length; i++) { for (var i=0; i<list.length; i++) {
var project = list[i]; var project = list[i];
@ -231,6 +230,15 @@
$('select#project_id').combobox('refresh'); $('select#project_id').combobox('refresh');
} }
function addProjectToMaps(project) {
var client = project.client;
projectMap[project.public_id] = project;
if (!projectsForClientMap.hasOwnProperty(client.public_id)) {
projectsForClientMap[client.public_id] = [];
}
projectsForClientMap[client.public_id].push(project);
}
$(function() { $(function() {
// setup clients and project comboboxes // setup clients and project comboboxes
@ -238,17 +246,7 @@
for (var i=0; i<projects.length; i++) { for (var i=0; i<projects.length; i++) {
var project = projects[i]; var project = projects[i];
projectMap[project.public_id] = project; addProjectToMaps(project)
var client = project.client;
if (!client) {
projectsForAllClients.push(project);
} else {
if (!projectsForClientMap.hasOwnProperty(client.public_id)) {
projectsForClientMap[client.public_id] = [];
}
projectsForClientMap[client.public_id].push(project);
}
} }
for (var i=0; i<clients.length; i++) { for (var i=0; i<clients.length; i++) {
@ -310,6 +308,12 @@
} }
}); });
Mousetrap.bind('/', function(e) {
console.log('clicked..');
event.preventDefault();
$('#search').focus();
});
@include('partials/entity_combobox', ['entityType' => ENTITY_PROJECT]) @include('partials/entity_combobox', ['entityType' => ENTITY_PROJECT])
$clientSelect.trigger('change'); $clientSelect.trigger('change');

View File

@ -35,15 +35,16 @@
success: function(response) { success: function(response) {
console.log(response); console.log(response);
var task = self.selectedTask(); var task = self.selectedTask();
if (task.isNew()) { var projectId = $('input[name=project_id]').val();
//self.addTask(task); if (projectId == -1) {
} else { var project = response.project;
//self.removeTask(task.original); project.client = response.client;
//self.addTask(task); projects.push(project);
addProjectToMaps(project);
refreshProjectList();
} }
task.update(response); task.update(response);
self.formChanged(false); self.formChanged(false);
//self.selectTask(task);
}, },
}); });
} }
@ -235,7 +236,7 @@
self.placeholder = ko.computed(function() { self.placeholder = ko.computed(function() {
if (self.selectedTask()) { if (self.selectedTask()) {
if (self.selectedTask().description()) { if (self.selectedTask().description()) {
return self.selectedTask().description(); return self.selectedTask().description.truncated();
} else { } else {
return "{{ trans('texts.no_description') }}" return "{{ trans('texts.no_description') }}"
} }