Permalink
Browse files

Update pickable usage on time entry form to get it working again

  • Loading branch information...
lovett committed Jan 6, 2017
1 parent d32dac6 commit f1077c9cd9132c11c0cf5edb369a8e5dca3eea65
View
@@ -108,7 +108,7 @@ public static function date(Carbon $value)
return $value->format('M n Y');
}
public static function dateField(Carbon $value)
public static function dateField(Carbon $value = null)
{
if (empty($value)) {
return '';
@@ -117,6 +117,16 @@ public static function dateField(Carbon $value)
return $value->format('Y-m-d');
}
public static function timeField(Carbon $value = null)
{
if (empty($valu)) {
return '';
}
return $value->format('g:i A');
}
public static function ranges() {
return [
'today' => new DateTime(),
@@ -77,12 +77,8 @@ public function create(Request $request)
$projectId = null;
}
$model = new Time(
[
'start' => new Carbon('now'),
'project_id' => $projectId,
]
);
$model = new Time();
$model->project_id = $projectId;
$previousModel = $request->user()->time();
if ($projectId !== null) {
View
@@ -18,6 +18,13 @@ class Time extends Model
{
use SoftDeletes, Search;
/**
* Default values for newly-created instances.
*
* @var array
*/
protected $attributes = [];
/**
* Fields that can be used for searching.
*
@@ -65,6 +72,18 @@ class Time extends Model
*/
protected $dates = ['deleted_at' => 'datetime'];
public function __construct()
{
$now = new Carbon();
$this->attributes = [
'start' => $now,
'minutes' => 0,
];
parent::__construct();
}
/**
* Master query for getting a list of records.
*
@@ -4,7 +4,7 @@
@endif
<div class="col-sm-10 {{ $label ? '' : 'col-sm-offset-2' }}">
{!! Form::text($name, TimeHelper::dateField($model->$name), ['class' => 'form-control']) !!}
{!! Form::text($name, TimeHelper::dateField($model->$name), ['class' => 'form-control', 'v-model' => 'pickResult']) !!}
@if (isset($autofill))
<autofill-hint target="INPUT[name={{ $name }}]" v-bind:value="suggested{{ ucfirst($name) }}" v-bind:previous="previous{{ ucfirst($name) }}"></autofill-hint>
@@ -4,46 +4,54 @@
@endif
<div class="col-sm-10 {{ $label ? '' : 'col-sm-offset-2' }}">
<pickable inline-template format="hh:mm AA" initial="{{ date('h:i A') }}">
{!! Form::text($name . $suffix, isset($model->$name)? $model->$name->format('g:i A') : '', ['class' => 'form-control', 'v-model' => 'pickResult']) !!}
{!! Form::text($fieldName, TimeHelper::timeField($model->$name), ['class' => 'form-control', 'v-model' => 'pickResult']) !!}
<p>
<a href="#" @click.prevent="toggle($event)" v-bind:class="{hidden: !isToggled}">
shortcuts
</a>
</p>
<pickable inline-template format="hh:mm AA" initial-value="{{ date('h:i A') }}" target="INPUT[name={{ $fieldName }}]">
<div>
<p>
<a href="#" @click.prevent="toggle($event)" v-bind:class="{hidden: isOpen}">
shortcuts
</a>
</p>
<div class="shortcuts" v-bind:class="{toggled: isToggled}">
<div class="well">
<p>
<span class="label">Hour:</span>
@foreach ($ranges['hour'] as $value)
<a @click.prevent="pick('hh', '{{ $value->format('g') }}')"
<div class="shortcuts" v-bind:class="{toggled: isOpen}">
<div class="well">
<p>
<span class="label">Hour:</span>
@foreach ($ranges['hour'] as $value)
<a @click.prevent="pick('hh', '{{ $value->format('g') }}')"
href="#"
>{{ $value->format('g') }}</a>
@endforeach
</p>
<p>
<span class="label">Minute:</span>
@foreach ($ranges['minute'] as $value)
<a @click.prevent="pick('mm', '{{ $value->format('i') }}')"
href="#"
>{{ $value->format('i') }}</a>
@endforeach
</p>
<p>
<a @click.prevent="pick('AA', 'AM')"
href="#"
>{{ $value->format('g') }}</a>
@endforeach
</p>
<p>
<span class="label">Minute:</span>
@foreach ($ranges['minute'] as $value)
<a @click.prevent="pick('mm', '{{ $value->format('i') }}')"
>AM</a>
<a @click.prevent="pick('AA', 'PM')"
href="#"
>{{ $value->format('i') }}</a>
@endforeach
</p>
<p>
<a @click.prevent="pick('AA', 'AM')"
href="#"
>AM</a>
<a @click.prevent="pick('AA', 'PM')"
href="#"
>PM</a>
</p>
>PM</a>
</p>
<p class="text-center">
<a class="small" href="#" @click.prevent="toggle($event)">
</a>
</p>
</div>
</div>
</div>
</pickable>
@if ($errors->has($name))
<div class="help-block">{{ $errors->first($name)}}</div>
@endif
@@ -22,10 +22,10 @@
@include('partials.formgroup-standard', ['name' => 'estimatedDuration', 'label' => 'Estimate'])
@include('partials.formgroup-date', ['name' => 'start', 'suffix' => 'Date', 'label' => 'Date', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-date', ['name' => 'start', 'label' => 'Date', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-time', ['name' => 'start', 'suffix' => 'Time', 'label' => 'Start', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-time', ['name' => 'end', 'suffix' => 'Time', 'label' => 'End', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-time', ['name' => 'start', 'fieldName' => 'startTime', 'label' => 'Start', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-time', ['name' => 'end', 'fieldName' => 'endTime', 'label' => 'End', 'ranges' => TimeHelper::ranges()])
@include('partials.formgroup-textarea', ['name' => 'summary', 'label' => 'Summary'])
@@ -58,5 +58,6 @@
@include('partials.vue')
<script src="{{ asset('js/pickable.js') }}"></script>
<script src="{{ asset('js/prefill.js') }}"></script>
@include('partials.vue-init');
@include('partials.select2')
@endsection
View
@@ -6,6 +6,8 @@ set -u
PROJECT_ROOT=$(pwd)
PROJECT_NAME=$(basename "$PROJECT_ROOT")
STARTPAGE="${STARTPAGE:-.}"
# Start the server if not already running
tmux start-server 2> /dev/null
@@ -15,7 +17,7 @@ tmux attach-session -d -t "$PROJECT_NAME" || {
## 0: Editor
tmux new-session -d -s "$PROJECT_NAME" bash
tmux send-keys -t "$PROJECT_NAME" "e ." C-m
tmux send-keys -t "$PROJECT_NAME" "$EDITOR $STARTPAGE" C-m
## 1: Shell
tmux new-window -a -t "$PROJECT_NAME" bash

0 comments on commit f1077c9

Please sign in to comment.