Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-26 11:54:56 +03:00
parent 4ff0a075ca
commit 16679e9973
2 changed files with 12 additions and 8 deletions

View File

@ -210,7 +210,7 @@
->large() ->large()
->appendIcon(Icon::create('floppy-disk')) ->appendIcon(Icon::create('floppy-disk'))
->withAttributes([ ->withAttributes([
'data-bind' => 'click: onSaveClick, css: { disabled: ! formChanged() }', 'data-bind' => 'click: onSaveClick, css: { disabled: ! formChanged() || ! isStartEnabled() }',
]) !!} ]) !!}
</center> </center>
</form> </form>
@ -465,7 +465,7 @@
if (isMobile) { if (isMobile) {
toastr.warning("{{ trans('texts.time_tracker_mobile_help')}}", false, { toastr.warning("{{ trans('texts.time_tracker_mobile_help')}}", false, {
timeOut: 10000, timeOut: 10000,
closeButton: true, closeButton: true,
}); });
if (isIPhone) { if (isIPhone) {
link = '{{ NINJA_IOS_APP_URL }}'; link = '{{ NINJA_IOS_APP_URL }}';

View File

@ -55,6 +55,7 @@
id: task.public_id(), id: task.public_id(),
action: action, action: action,
} }
self.isStartEnabled(false);
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
type: 'post', type: 'post',
@ -79,8 +80,11 @@
}, },
error: function(error) { error: function(error) {
toastr.error("{{ trans('texts.error_refresh_page') }}"); toastr.error("{{ trans('texts.error_refresh_page') }}");
swal('failed to bulk save');
} }
}).always(function() {
setTimeout(function() {
model.isStartEnabled(true);
}, 1000);
}); });
} }
@ -438,7 +442,6 @@
self.save = function(data, isSelected) { self.save = function(data, isSelected) {
if (self.isValid() !== true) { if (self.isValid() !== true) {
toastr.error("{{ trans('texts.error_refresh_page') }}"); toastr.error("{{ trans('texts.error_refresh_page') }}");
swal('not valid on save');
throw self.isValid(); throw self.isValid();
return; return;
} }
@ -453,6 +456,7 @@
} else { } else {
data += '&is_running=0'; data += '&is_running=0';
} }
model.isStartEnabled(false);
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
type: method, type: method,
@ -502,14 +506,14 @@
} }
} }
model.refreshTitle(); model.refreshTitle();
setTimeout(function() {
model.isStartEnabled(true);
}, 1000);
}, },
error: function(error) { error: function(error) {
toastr.error("{{ trans('texts.error_refresh_page') }}"); toastr.error("{{ trans('texts.error_refresh_page') }}");
swal('failed to save');
}, },
}).always(function() {
setTimeout(function() {
model.isStartEnabled(true);
}, 1000);
}); });
} }