I'm making a task management tool and my app needs the capability of creating repeating tasks, so I'm trying to emulate Google Calendar's "repeating event" menu. This one:
As you can see, when you check the boxes for the days of the week you want, the "Summary" field updates automatically with the days you have selected. How would I achieve this using AngularJS or JQuery?
The rest of the "Summary" options I did using ng-if
, like this:
<div ng-if="recurrence_type === 'Weekly'">
<div ng-if="recurrence_pattern === '1' && !recurrence_frequency && !recurrence_end">
<p class="form-control-static"><b>Weekly</b></p>
</div>
<div ng-if="recurrence_pattern > '1' && !recurrence_frequency && !recurrence_end">
<p class="form-control-static"><b>Every weeks</b></p>
</div>
<div ng-if="recurrence_pattern === '1' && recurrence_frequency && !recurrence_end">
<p class="form-control-static"><b>Weekly, times</b></p>
</div>
<div ng-if="recurrence_pattern > '1' && recurrence_frequency && !recurrence_end">
<p class="form-control-static"><b>Every weeks,
times</b></p>
</div>
<div ng-if="recurrence_pattern === '1' && !recurrence_frequency && recurrence_end">
<p class="form-control-static"><b>Weekly, until </b></p>
</div>
<div ng-if="recurrence_pattern > '1' && !recurrence_frequency && recurrence_end">
<p class="form-control-static"><b>Every weeks, until
</b></p>
</div>
</div>
Where:
recurrence_pattern
is the number of weeks;recurrence_frequency
is the number of occurrences;recurrence_end
is the end date.
I mean, I could do it like I've been doing so far, using ng-if
, but I would have to make a ng-if
for every single combination of checkboxes and I'd be here all day. I'm betting there's an easier way.
This is my code for the checkboxes:
<label class="col-sm-3 control-label">Repeat on:</label>
<label class="checkbox-inline">
<input type="checkbox" id="monday" title="Monday" value="Monday"> M
</label>
<label class="checkbox-inline">
<input type="checkbox" id="tuesday" title="Tuesday" value="Tuesday"> T
</label>
<label class="checkbox-inline">
<input type="checkbox" id="wednesday" title="Wednesday" value="Wednesday"> W
</label>
<label class="checkbox-inline">
<input type="checkbox" id="thursday" title="Thursday" value="Thursday"> T
</label>
<label class="checkbox-inline">
<input type="checkbox" id="friday" title="Friday" value="Friday"> F
</label>
<label class="checkbox-inline">
<input type="checkbox" id="saturday" title="Saturday" value="Saturday"> S
</label>
<label class="checkbox-inline">
<input type="checkbox" id="sunday" title="Sunday" value="Sunday"> S
</label>
Again, the technologies I'm using is JavaScript with AngularJS, but I also have JQuery available since I'm using Bootstrap 3.
Thank you.
Aucun commentaire:
Enregistrer un commentaire