Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoerr committed Jan 11, 2018
2 parents 740cde5 + 63abd06 commit 3a56def
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ public function session() {
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function actions() {
return $this->hasMany(Action::class, 'BillId');
return $this->hasMany(Action::class, 'BillId')->where("ActionType", "!=", 0);
}

/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function scheduledActions() {
return $this->hasMany(ScheduledAction::class, 'BillId');
return $this->hasMany(ScheduledAction::class, 'BillId')->where("ActionType", "!=", 0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/ScheduledAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ScheduledAction extends Model
* @var array
*/
protected $fillable = [
'Link','Date', 'Chamber', 'Start', 'End', 'Location'
'Link','Date', 'Chamber', 'Start', 'End', 'Location', 'CustomStart'
];

/**
Expand Down
4 changes: 2 additions & 2 deletions config/enums.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
],
'ActionTypes' => [
0 => "Unknown",
1 => "Committee Reading",
1 => "Committee Hearing",
2 => "Second Reading",
3 => "Third Reading",
4 => "Assigned To Committee",
4 => "Committee Assigned",
5 => "Sent to Governor",
6 => "Signed by Governor",
7 => "Vetoed by Governor",
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
|
*/

'lifetime' => 120,
'lifetime' => 10080,

'expire_on_close' => false,

Expand Down
13 changes: 3 additions & 10 deletions resources/assets/js/components/all-bills.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
const pageSize = 50
const billLoader = require('../bill-loader.js');
const mapGetters = require('vuex').mapGetters
const {getQueryVariable, updateQueryVariable} = require('../utilities')
const {getQueryVariable, updateQueryVariable, filterBills} = require('../utilities')
module.exports = {
components: {
Expand Down Expand Up @@ -117,22 +117,15 @@
getFilteredBills() {
if(this.q.length > 0) {
this.isFilterApplied = true
let query = this.q.toLowerCase()
var containsQuery = (str) => str.toLowerCase().indexOf(query) !== -1
return this.bills.filter( bill =>
containsQuery(bill.Name)
|| (bill.subjects.some (element => containsQuery(element.Name)))
|| (bill.committees.some (element => containsQuery(element.Name)))
|| containsQuery(bill.Title)
|| containsQuery(bill.Description))
return filterBills(this.bills, this.q)
} else {
this.isFilterApplied = false
return this.bills
}
},
filterBillHandler(supressHistory) {
this.filteredBills = this.getFilteredBills()
if(this.currentPage > this.nPages-1) {
if(this.nPages > 0 && this.currentPage > this.nPages-1) {
this.currentPage = this.nPages-1
}
Expand Down
18 changes: 11 additions & 7 deletions resources/assets/js/components/bill-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<div v-if="bill.actions && bill.actions[0]">
<div class="bill-table__action-type">({{bill.actions[0].Chamber.substr(0,1)}}) {{bill.actions[0].ActionType}}</div>
<div class="bill-table__action-details">
{{bill.actions[0].Description}}<br>
<em>{{bill.actions[0].Description}}</em><br>
{{formatDate(bill.actions[0].Date)}}
</div>
</div>
Expand All @@ -87,10 +87,16 @@
<div v-if="bill.scheduled_actions && bill.scheduled_actions[0]">
<div class="bill-table__action-type">({{bill.scheduled_actions[0].Chamber.substr(0,1)}}) {{bill.scheduled_actions[0].ActionType}}</div>
<div class="bill-table__action-details">{{formatDate(bill.scheduled_actions[0].Date)}}<br>
<div v-if="bill.scheduled_actions[0].Start">
{{formatTime(bill.scheduled_actions[0].Start)}} - {{formatTime(bill.scheduled_actions[0].End)}}<br>
<div v-if="bill.scheduled_actions[0].Start && bill.scheduled_actions[0].End">
{{bill.scheduled_actions[0].Start}} - {{bill.scheduled_actions[0].End}}<br>
</div>
{{bill.scheduled_actions[0].Location}}
<div v-if="bill.scheduled_actions[0].Start && !bill.scheduled_actions[0].End">
{{bill.scheduled_actions[0].Start}}<br>
</div>
<div v-if="bill.scheduled_actions[0].CustomStart && bill.scheduled_actions[0].CustomStart !== '' ">
{{bill.scheduled_actions[0].CustomStart}}<br>
</div>
<a href="http://iga.in.gov/information/location_maps/">{{bill.scheduled_actions[0].Location}}</a>
</div>
</div>
<div v-else>
Expand Down Expand Up @@ -139,9 +145,7 @@
formatDate(dateToFormat) {
return moment(dateToFormat, 'YYYY-MM-DD').format('dddd, MMMM Do')
},
formatTime(timeToFormat) {
return moment('01/01/0001 ' + timeToFormat, 'MM/DD/YYYY HH:mm:ss').format('h:mma')
},
toggleTrackingHandler(id) {
if(this.isTracked(id)) {
this.stopTrackingHandler(id);
Expand Down
10 changes: 2 additions & 8 deletions resources/assets/js/components/my-bills.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
const billLoader = require('../bill-loader.js')
const mapGetters = require("vuex").mapGetters
const mapActions = require("vuex").mapActions
const { filterBills } = require('../utilities')
module.exports = {
components: {
Expand All @@ -43,14 +44,7 @@
filteredBills() {
if(this.q.length > 0) {
this.isFilterApplied = true
let query = this.q.toLowerCase()
var containsQuery = (str) => str.toLowerCase().indexOf(query) !== -1
return this.myBills.filter( bill =>
containsQuery(bill.Name)
|| (bill.subjects.some (element => containsQuery(element.Name)))
|| (bill.committees.some (element => containsQuery(element.Name)))
|| containsQuery(bill.Title)
|| containsQuery(bill.Description))
return filterBills(this.bills, this.q)
} else {
this.isFilterApplied = false
return this.myBills
Expand Down
37 changes: 36 additions & 1 deletion resources/assets/js/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,42 @@ const updateQueryVariable = (key, value, url) => {
}
}

const contains = (str, sub) => str.indexOf(sub) !== -1;
/// remove spaces from a string
const removeSpaces = (str) => str.replace(' ','');
/// determines whether this bill's display name ("SB 123") is contained
/// in a list of possible bill names and/or if its number ("123") is
/// contained in a list of possible bill numbers.
const containsBillName = (name, qNames, qNumbers) => {
const lower = name.toLowerCase(); // "sb 123"
const bName = removeSpaces(lower); // "sb123"
const bNum = bName.substring(2); // "123"
return qNames.some(q => q === bName)
|| qNumbers.some(q => q === bNum);
};

/// filter bills to those matching the search string.
const filterBills = (bills, query) => {
const q = query.toLowerCase();
// find parts of the query string matching a bill name ("sb 123", "hb1004") or number ("123", "1004")
const l = q.match(/([hs][bcjr]\s*)?(\d*)/g).map(s=>removeSpaces(s));
const qNames = l.filter(s=>/^[sh]+/.test(s)); // those like "sb 123", "hb1004"
const qNumbers = l.filter(s=>/^[0-9]+/.test(s)); // those like "123", "1004"
const matchesName = (b) => containsBillName(b.DisplayName, qNames, qNumbers);
const matchesSubjects = (b) => b.subjects.some(e=>contains(e.Name,q));
const matchesCommittees = (b) => b.committees.some(e=>contains(e.Name,q));
const matchesTitle = (b) => contains(b.Title,q);
const matchesDescription = (b) => contains(b.Description,q);
return bills.filter(b =>
matchesName(b)
|| matchesSubjects(b)
|| matchesCommittees(b)
|| matchesTitle(b)
|| matchesDescription(b));
}

export {
getQueryVariable,
updateQueryVariable
updateQueryVariable,
filterBills
}

0 comments on commit 3a56def

Please sign in to comment.