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:
parent
519e3a39db
commit
4117c71215
@ -13,6 +13,17 @@ class TaskRequest extends EntityRequest
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
|
// check if we're creating a new client
|
||||||
|
if ($this->client_id == '-1') {
|
||||||
|
$client = [
|
||||||
|
'name' => trim($this->client_name),
|
||||||
|
];
|
||||||
|
if (Client::validate($client) === true) {
|
||||||
|
$client = app('App\Ninja\Repositories\ClientRepository')->save($client);
|
||||||
|
$input['client_id'] = $this->client_id = $client->public_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if we're creating a new project
|
// check if we're creating a new project
|
||||||
if ($this->project_id == '-1') {
|
if ($this->project_id == '-1') {
|
||||||
$project = [
|
$project = [
|
||||||
|
@ -2458,6 +2458,7 @@ $LANG = array(
|
|||||||
'discard_changes' => 'Discard Changes',
|
'discard_changes' => 'Discard Changes',
|
||||||
'tasks_not_enabled' => 'Tasks are not enabled.',
|
'tasks_not_enabled' => 'Tasks are not enabled.',
|
||||||
'started_task' => 'Successfully started task',
|
'started_task' => 'Successfully started task',
|
||||||
|
'create_client' => 'Create Client',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ var {{ $entityType }}Name = '';
|
|||||||
|
|
||||||
${{ $entityType }}Select.combobox({
|
${{ $entityType }}Select.combobox({
|
||||||
highlighter: function (item) {
|
highlighter: function (item) {
|
||||||
|
console.log(item);
|
||||||
if (item.indexOf("{{ trans("texts.create_{$entityType}") }}") == 0) {
|
if (item.indexOf("{{ trans("texts.create_{$entityType}") }}") == 0) {
|
||||||
{{ $entityType }}Name = this.query;
|
{{ $entityType }}Name = this.query;
|
||||||
return "{{ trans("texts.create_{$entityType}") }}: " + this.query;
|
return "{{ trans("texts.create_{$entityType}") }}: " + this.query;
|
||||||
|
@ -242,26 +242,58 @@
|
|||||||
var projectMap = {};
|
var projectMap = {};
|
||||||
var projectsForClientMap = {};
|
var projectsForClientMap = {};
|
||||||
|
|
||||||
|
function refreshClientList() {
|
||||||
|
var $clientSelect = $('select#client_id');
|
||||||
|
$clientSelect.find('option').remove().end().combobox('refresh');
|
||||||
|
$clientSelect.append(new Option('', ''));
|
||||||
|
|
||||||
|
@if (Auth::user()->can('create', ENTITY_CLIENT))
|
||||||
|
$clientSelect.append(new Option("{{ trans('texts.create_client')}}: $name", '-1'));
|
||||||
|
@endif
|
||||||
|
|
||||||
|
for (var i=0; i<clients.length; i++) {
|
||||||
|
var client = clients[i];
|
||||||
|
var clientName = getClientDisplayName(client);
|
||||||
|
if (!clientName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
|
}
|
||||||
|
$('select#client_id').combobox('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
function refreshProjectList(forceClear) {
|
function refreshProjectList(forceClear) {
|
||||||
|
console.log('refreshProjectList...');
|
||||||
var clientId = $('input[name=client_id]').val();
|
var clientId = $('input[name=client_id]').val();
|
||||||
$projectCombobox = $('select#project_id');
|
$projectCombobox = $('select#project_id');
|
||||||
$projectCombobox.find('option').remove().end().combobox('refresh');
|
$projectCombobox.find('option').remove().end().combobox('refresh');
|
||||||
$projectCombobox.append(new Option('', ''));
|
$projectCombobox.append(new Option('', ''));
|
||||||
|
|
||||||
@if (Auth::user()->can('create', ENTITY_PROJECT))
|
@if (Auth::user()->can('create', ENTITY_PROJECT))
|
||||||
if (clientId) {
|
if (clientId) {
|
||||||
$projectCombobox.append(new Option("{{ trans('texts.create_project')}}: $name", '-1'));
|
$projectCombobox.append(new Option("{{ trans('texts.create_project')}}: $name", '-1'));
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
var list = (clientId && ! forceClear) ? (projectsForClientMap.hasOwnProperty(clientId) ? projectsForClientMap[clientId] : []) : projects;
|
if (clientId && ! forceClear) {
|
||||||
|
var list = projectsForClientMap.hasOwnProperty(clientId) ? projectsForClientMap[clientId] : [];
|
||||||
|
console.log('client list: ' + clientId);
|
||||||
|
} else {
|
||||||
|
var list = 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];
|
||||||
$projectCombobox.append(new Option(project.name, project.public_id));
|
$projectCombobox.append(new Option(project.name, project.public_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('select#project_id').combobox('refresh');
|
$('select#project_id').combobox('refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addClientToMaps(client) {
|
||||||
|
clientMap[client.public_id] = client;
|
||||||
|
}
|
||||||
|
|
||||||
function addProjectToMaps(project) {
|
function addProjectToMaps(project) {
|
||||||
var client = project.client;
|
var client = project.client;
|
||||||
projectMap[project.public_id] = project;
|
projectMap[project.public_id] = project;
|
||||||
@ -274,29 +306,16 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// setup clients and project comboboxes
|
// setup clients and project comboboxes
|
||||||
var $clientSelect = $('select#client_id');
|
|
||||||
|
|
||||||
for (var i=0; i<projects.length; i++) {
|
for (var i=0; i<projects.length; i++) {
|
||||||
var project = projects[i];
|
addProjectToMaps(projects[i])
|
||||||
addProjectToMaps(project)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
addClientToMaps(clients[i]);
|
||||||
clientMap[client.public_id] = client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.append(new Option('', ''));
|
var $clientSelect = $('select#client_id');
|
||||||
for (var i=0; i<clients.length; i++) {
|
//$clientSelect.combobox();
|
||||||
var client = clients[i];
|
|
||||||
var clientName = getClientDisplayName(client);
|
|
||||||
if (!clientName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$clientSelect.append(new Option(clientName, client.public_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
$clientSelect.combobox();
|
|
||||||
$clientSelect.on('change', function(e) {
|
$clientSelect.on('change', function(e) {
|
||||||
var clientId = $('input[name=client_id]').val();
|
var clientId = $('input[name=client_id]').val();
|
||||||
var projectId = $('input[name=project_id]').val();
|
var projectId = $('input[name=project_id]').val();
|
||||||
@ -345,8 +364,10 @@
|
|||||||
$('#search').focus();
|
$('#search').focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@include('partials/entity_combobox', ['entityType' => ENTITY_CLIENT])
|
||||||
@include('partials/entity_combobox', ['entityType' => ENTITY_PROJECT])
|
@include('partials/entity_combobox', ['entityType' => ENTITY_PROJECT])
|
||||||
|
|
||||||
|
refreshClientList();
|
||||||
$clientSelect.trigger('change');
|
$clientSelect.trigger('change');
|
||||||
|
|
||||||
window.model = new ViewModel();
|
window.model = new ViewModel();
|
||||||
@ -363,7 +384,6 @@
|
|||||||
var taskId = localStorage.getItem('last:time_tracker_task');
|
var taskId = localStorage.getItem('last:time_tracker_task');
|
||||||
var task = model.taskById(taskId);
|
var task = model.taskById(taskId);
|
||||||
if (task) {
|
if (task) {
|
||||||
console.log(task);
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
model.selectTask(task);
|
model.selectTask(task);
|
||||||
}, 1);
|
}, 1);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.onFilterClick = function() {
|
self.onFilterClick = function() {
|
||||||
console.log('filter...');
|
console.log('filter clicked...');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.onRefreshClick = function() {
|
self.onRefreshClick = function() {
|
||||||
@ -425,6 +425,16 @@
|
|||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
|
var isNew = !self.public_id();
|
||||||
|
self.update(response);
|
||||||
|
model.formChanged(false);
|
||||||
|
var clientId = $('input[name=client_id]').val();
|
||||||
|
if (clientId) {
|
||||||
|
var client = response.client;
|
||||||
|
clients.push(client);
|
||||||
|
addClientToMaps(client);
|
||||||
|
refreshClientList();
|
||||||
|
}
|
||||||
var projectId = $('input[name=project_id]').val();
|
var projectId = $('input[name=project_id]').val();
|
||||||
if (projectId == -1) {
|
if (projectId == -1) {
|
||||||
var project = response.project;
|
var project = response.project;
|
||||||
@ -433,9 +443,6 @@
|
|||||||
addProjectToMaps(project);
|
addProjectToMaps(project);
|
||||||
refreshProjectList();
|
refreshProjectList();
|
||||||
}
|
}
|
||||||
var isNew = !self.public_id();
|
|
||||||
self.update(response);
|
|
||||||
model.formChanged(false);
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
toastr.success("{{ trans('texts.created_task') }}");
|
toastr.success("{{ trans('texts.created_task') }}");
|
||||||
} else {
|
} else {
|
||||||
@ -687,7 +694,7 @@
|
|||||||
|
|
||||||
function ClientModel(data) {
|
function ClientModel(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.public_id = ko.observable(0);
|
self.public_id = ko.observable(-1);
|
||||||
self.name = ko.observable('');
|
self.name = ko.observable('');
|
||||||
self.contacts = ko.observableArray();
|
self.contacts = ko.observableArray();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user