Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date and Date Range Selection Components #178

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
761a519
Provided a dropdown list of crops,in alphabetical order, from the far…
Apr 5, 2021
7ddddf9
Added start date and end date inputs to the tray seeding report tab, …
josieecook Apr 6, 2021
496d4bc
Added comments to traySeedingReport.html for better readability
josieecook Apr 11, 2021
04efe74
Added a traySeedingLogRequest method that will make an API request to…
josieecook Apr 11, 2021
50e3364
Added a traySeedingLogRequest method that sends an API request for tr…
josieecook Apr 11, 2021
3692c00
Added generate report button and a mock report table
ShannonLoughin Apr 11, 2021
d18ed65
Merge branch 'TraySeedingDates' into task-delete
josieecook Apr 11, 2021
0bfc4a1
Merge branch 'TraySeedingDates' into task-delete
josieecook Apr 11, 2021
efcfc25
Merge pull request #3 from josieecook/task-delete
josieecook Apr 11, 2021
68a1fb6
Merge pull request #2 from josieecook/task-delete
Diego2214 Apr 12, 2021
ae75786
Added All option to crop downdown
Apr 12, 2021
b858ab2
Merge branch 'main' into cropTaskBranch1
Diego2214 Apr 12, 2021
e006606
Merge pull request #4 from josieecook/cropTaskBranch1
Diego2214 Apr 12, 2021
f58fcf9
Cleaned Up code and made sure date/crops appear on table
Apr 13, 2021
499a4e4
Merge pull request #5 from josieecook/cropTaskBranch1
Diego2214 Apr 13, 2021
d9ff5d2
Cleaned up generateReport function
Apr 13, 2021
aa7270b
Merge pull request #6 from josieecook/cropTaskBranch1
Diego2214 Apr 13, 2021
f76eb35
Merge pull request #7 from josieecook/main
josieecook Apr 14, 2021
1bc0aba
Merge branch 'TraySeedingDates' into requestWithDates
josieecook Apr 14, 2021
8302424
Merge pull request #8 from josieecook/requestWithDates
josieecook Apr 14, 2021
cff4ea2
Added delete button and popup message upon clicking button
ShannonLoughin Apr 14, 2021
06b8952
Merge pull request #9 from josieecook/TraySeedingDates
josieecook Apr 14, 2021
c77db13
Merge branch 'task-delete' of https://github.com/josieecook/FarmData2…
ShannonLoughin Apr 14, 2021
7037bcf
Merge branch 'main' into task-delete
josieecook Apr 14, 2021
e27d4aa
Merge pull request #10 from josieecook/task-delete
josieecook Apr 14, 2021
3b56b5c
Added notes to guide future coding
Apr 14, 2021
a2f7c59
Code clean up from delete button and row dates merge
Apr 14, 2021
2de4fb1
Merge branch 'main' into cropTaskBranch1
Diego2214 Apr 14, 2021
e638cfb
Merge pull request #11 from josieecook/cropTaskBranch1
Diego2214 Apr 14, 2021
fee539d
added delete button to cleaned up code
ShannonLoughin Apr 16, 2021
8a57f10
Merge pull request #12 from josieecook/task-delete
Diego2214 Apr 18, 2021
a132151
Merge pull request #13 from josieecook/main
Diego2214 Apr 18, 2021
a839956
Table now gives crop output from API and the 'All' crops option now w…
Apr 18, 2021
6ea8d5a
Merge pull request #14 from josieecook/cropTaskBranch1
Diego2214 Apr 18, 2021
0b4993d
Fully functioning delete button
ShannonLoughin Apr 21, 2021
d3c9160
Merge branch 'main' of https://github.com/josieecook/FarmData2 into t…
ShannonLoughin Apr 21, 2021
41eda42
Merge pull request #15 from josieecook/task-delete
ShannonLoughin Apr 21, 2021
024920c
Returned main to original upstream code by removing file traySeedingR…
josieecook Apr 21, 2021
d9ab6b6
Deleted traySeedingReport.html in main
josieecook Apr 21, 2021
69daae2
Merge branch 'main' of https://github.com/josieecook/FarmData2 into main
josieecook Apr 21, 2021
c8b6ccd
Merge branch 'main' of https://github.com/DickinsonCollege/FarmData2 …
josieecook May 2, 2021
ddabddc
Merge branch 'main' into CropAndFieldPickers
josieecook Jun 2, 2021
af9ed11
Fixed merge conflicts with upstream and main to stay up to date.
josieecook Jun 7, 2021
b12c968
Commiting progress in the cypress tests of the crop and field drop-do…
josieecook Jun 7, 2021
446b81f
Crop and Field Picker component and cypress tests in progress
josieecook Jun 8, 2021
fd7a39f
Updated dropdown component with new name, more consistent labels, and…
josieecook Jun 8, 2021
675ffaf
Merge branch 'main' into CropAndFieldPickers
josieecook Jun 2, 2021
dead1f5
Merge branch 'main' of https://github.com/DickinsonCollege/FarmData2 …
josieecook Jun 8, 2021
0177b75
achieved functional dropdownWithAll component and component testing f…
josieecook Jun 8, 2021
354d030
Merge branch 'CropAndFieldPickers' of https://github.com/josieecook/F…
josieecook Jun 8, 2021
9a677e3
partial progress on switching the example file to using the new dropd…
josieecook Jun 8, 2021
a573848
added dateComponent.js and dateComponent.spec.comp.js to the resourse…
IrisSC Jun 8, 2021
6ef2c35
Finishd the new DropdownWithAllComponent and implemented it in the ex…
josieecook Jun 9, 2021
9b61f9e
Merge branch 'main' of https://github.com/DickinsonCollege/FarmData2 …
josieecook Jun 9, 2021
810a4db
Merge branch 'main' of https://github.com/DickinsonCollege/FarmData2 …
IrisSC Jun 9, 2021
57c41b6
Merge branch 'main' into CropAndFieldPickers
josieecook Jun 9, 2021
7286b0b
Removed old unnecessary tabs and code and reworked the end-to-end cyp…
josieecook Jun 9, 2021
79d659a
Partial progress on date selection cypress tests
josieecook Jun 9, 2021
c74107c
Finished implementation and cypress testing of the dateSelection comp…
josieecook Jun 9, 2021
ed5bb6d
In progree date range seletion components and tests
josieecook Jun 9, 2021
ac2196f
Cleaned up code for pull request to upstream, branch now only include…
josieecook Jun 10, 2021
8582c13
In progress, individual component test files for DateSeletion and Dat…
josieecook Jun 10, 2021
2c6603f
Merge pull request #11 from josieecook/DateSelectionComponent
IrisSC Jun 10, 2021
fb191ae
In progress attempting to figure out how to keep the components funct…
josieecook Jun 10, 2021
95645ef
Merge branch 'testDate' of https://github.com/IrisSC/FarmData2 into t…
IrisSC Jun 10, 2021
6c0e314
Removed the fieldDropdownComponent and added to DropdownWithAllCompon…
josieecook Jun 10, 2021
a0510d3
minor code fix
josieecook Jun 10, 2021
f864d3a
added table component and test file for table component
IrisSC Jun 10, 2021
9f74c8d
Merge branch 'TableComponent' into tableComponent
josieecook Jun 10, 2021
4496baa
merged with the main branch from upstream
IrisSC Jun 10, 2021
cfda8dc
Merge pull request #26 from IrisSC/tableComponent
josieecook Jun 10, 2021
76ec724
added cypress tests for table component
IrisSC Jun 10, 2021
94f99c2
Merge branch 'main' of https://github.com/DickinsonCollege/FarmData2 …
josieecook Jun 11, 2021
23f6eaa
Merges with main to keep up-to date
josieecook Jun 11, 2021
96f7a35
Merge branch 'TableComponent' into tableComponent
josieecook Jun 11, 2021
008de2a
Merge pull request #27 from IrisSC/tableComponent
josieecook Jun 11, 2021
a5be1fc
Merged with main
josieecook Jun 11, 2021
9a1a7be
minor changes
josieecook Jun 11, 2021
e626679
Fixed the import statements in the date and date range selection comp…
josieecook Jun 11, 2021
ffa1f3d
Merge pull request #12 from josieecook/DateAndDateRangeSelection
IrisSC Jun 11, 2021
3e19f73
Merge branch 'testDate' of https://github.com/IrisSC/FarmData2 into t…
IrisSC Jun 11, 2021
c0f2bae
Updated import statments in the component and component tests to matc…
josieecook Jun 11, 2021
b3f5b69
Updated cypress tests to be more efficient in their use of mounts
josieecook Jun 11, 2021
a372d21
Added defaultInput property to DropdownWithAllComponent and added an …
josieecook Jun 11, 2021
dfa874a
date components and cypress testing for the date components
IrisSC Jun 11, 2021
c707ec6
All cypress tests for the table component are passing
josieecook Jun 11, 2021
efe3521
Added a cypress test that passes if an event is emitted when the sele…
josieecook Jun 11, 2021
be06f83
Merge branch 'ComponentPlayground' into CropAndFieldPickers
josieecook Jun 11, 2021
eac9345
Merge pull request #28 from josieecook/CropAndFieldPickers
josieecook Jun 11, 2021
5a3b732
added emit cypress test for dateSelectionComponent
IrisSC Jun 11, 2021
320bd85
Merge branch 'ComponentPlayground' into TableComponent
josieecook Jun 11, 2021
6e36496
Merge pull request #29 from josieecook/TableComponent
josieecook Jun 11, 2021
7881634
Merge pull request #30 from IrisSC/dateSelectionComponents
josieecook Jun 11, 2021
0723065
Merge branch 'ComponentPlayground' into DateAndDateRangeSelection
josieecook Jun 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions farmdata2_modules/fd2_tabs/fd2_example/ex1.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- define a div to wrqp around the app. -->
<!-- apply v-cloak so that app is not visible until after being rendered -->
<div id="ex1" v-cloak>

<p>UserID: <span data-cy="user-id">{{ userID }}</span></p>
<p>UserName: <span data-cy="user-name">{{ userName }}</span></p>

Expand All @@ -14,11 +14,22 @@
<p>Farm Name: <span data-cy="farm-name">{{ farm }}</span></p>

<!-- Exmaple of using a Vue Component -->
<!-- the date-selection and date-range-selection components are defined in ../resources/DateSelectionComponent.js and ../resources/DateRangeSelectionComponent.js -->
<!-- That file is imported by the fd2_example.info file -->
<date-selection default-date="2021-06-08" latest-date="2022-12-31" earliest-date="2020-01-01"></date-selection>

<br>

<date-range-selection default-start-date="2021-02-01" default-end-date="2021-11-01"></date-range-selection>

<!-- the dropdown-with-all component is defined in ../resources/dropdownWithAllComponent.js -->
<!-- That file is imported by the fd2_example.info file -->
<dropdown-with-all includes-all @selection-changed='fieldChange' :dropdown-list=fieldList></dropdown-with-all>
<p>Chosen Field: <span data-cy="selected-field">{{selectedField}}</span></p>

<br>

<custom-table :headers="testArray" :rows="testObjectArray" can-edit can-delete @delete-row="deleteFromTestObjectArray" @finish-row-edit="updateTestObjectArray"></custom-table>

</div>

<script>
Expand All @@ -29,6 +40,9 @@
el: '#ex1',
components: {
// Register the components that are being used.
'date-selection': DateSelectionComponent,
'date-range-selection': DateRangeSelectionComponent,
customTable: CustomTableComponent,
'dropdown-with-all': DropdownWithAllComponent
},
data: {
Expand All @@ -38,6 +52,15 @@
fieldList: [],
userID: fd2UserID,
userName: fd2UserName,
testArray: ['cool', 'works?', 'hello'],
testObjectArray: [
{id: 10,
data: [12, 3, 'answome']},
{id: 11,
data: [19, 3, 'ansekjdwome'],},
{id: 12,
data: [12, 12, 'answome12'],},
],
},
created() {
axios
Expand All @@ -60,11 +83,28 @@
.then(response => (this.farm = response.data.name))
.catch(error => console.log(error))
},
fieldChange(newField) {
this.selectedField = newField;
},
updateTestObjectArray(newObject){
for(i=0; i < this.testObjectArray.length; i++){
if(array[i].id === newObject.id){
this.testObjectArray.splice(i, 1, newObject)
}
}
},
deleteFromTestObjectArray(deletedObjectID){
for(var i=0; i < this.testObjectArray.length; i++){
if(this.testObjectArray[i].id === deletedObjectID){
this.testObjectArray.splice(i, 1)
}
}
},
fieldChange(selectedOption) {
this.selectedField = selectedOption;
}
}
});
})

Vue.config.devtools = true;
</script>
5 changes: 4 additions & 1 deletion farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ core = 7.x
package = FarmData2

stylesheets[all][] = '../resources/fd2.css'
scripts[] = '../resources/dropdownWithAllComponent.js'
scripts[] = '../resources/DateSelectionComponent.js'
scripts[] = '../resources/DateRangeSelectionComponent.js'
scripts[] = '../resources/dropdownWithAllComponent.js'
scripts[] = '../resources/customTableComponent.js'
1 change: 1 addition & 0 deletions farmdata2_modules/fd2_tabs/fd2_example/testComponents.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
try {
DateSelectionComponent
}
catch(err) {
var DateComps = require("./DateSelectionComponent.js")
DateSelectionComponent = DateComps.DateSelectionComponent
}

let DateRangeSelectionComponent = {
template: `<div>
<date-selection data-cy="start-date-select" :defaultDate="defaultStartDate" :latestDate="latestStartDate" @dateChanged="startDateChange">
Start Date:
</date-selection>
<date-selection data-cy="end-date-select" :defaultDate="defaultEndDate" :earliestDate="earliestEndDate" @dateChanged="endDateChange">
End Date:
</date-selection>
</div>
`,
props: {
defaultStartDate:{
type: String,
required: true
},
defaultEndDate:{
type: String,
required: true
}
},
components: {
'date-selection': DateSelectionComponent,
},
data(){
return{
earliestEndDate: this.defaultStartDate,
latestStartDate: this.defaultEndDate,
}
},
methods: {
startDateChange(selectedDate){
this.earliestEndDate = selectedDate
},
endDateChange(selectedDate){
this.latestStartDate=selectedDate
},
},
}

try {
module.exports = {
DateRangeSelectionComponent: DateRangeSelectionComponent
}
}
catch(err) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { mount } from '@cypress/vue'

var DateComps = require("./DateRangeSelectionComponent.js")
var DateRangeSelectionComponent = DateComps.DateRangeSelectionComponent

describe('date range selection component', () => {
beforeEach(() => {
mount(DateRangeSelectionComponent, {
propsData: {
defaultStartDate: "2021-01-01",
defaultEndDate: "2021-12-01"
}
})
})
it('exists', () => {
cy.get('[data-cy=start-date-select]')
.should('exist')

cy.get('[data-cy=end-date-select]')
.should('exist')
})
it('fail to change start date to after end date', () => {
cy.get('[data-cy=start-date-select]')
.children()
.type('2056-01-01')
.blur()
.should('have.value', '2021-12-01')
})
it('fail to change end date to before start date', () => {
cy.get('[data-cy=end-date-select]')
.children()
.type('2000-01-01')
.blur()
.should('have.value', '2021-01-01')
})
})
41 changes: 41 additions & 0 deletions farmdata2_modules/fd2_tabs/resources/DateSelectionComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
let DateSelectionComponent = {
template: `<div>
<slot></slot>
<input data-cy="date-select" type="date" :min="earliestDate" :max="latestDate" id="date" v-model="selectedDate" @focusout="checkBounds">
</div>`,
props: {
defaultDate: {
type: String,
required: true,
},
earliestDate: {
type: String,
},
latestDate: {
type: String,
},
},
data(){
return {
selectedDate: this.defaultDate,
}
},
methods: {
checkBounds() {
if (this.selectedDate > this.latestDate) {
this.selectedDate = this.latestDate;
}
else if (this.selectedDate < this.earliestDate) {
this.selectedDate = this.earliestDate;
}
this.$emit('dateChanged', this.selectedDate)
}
},
}

try {
module.exports = {
DateSelectionComponent: DateSelectionComponent
}
}
catch(err) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { mount } from '@cypress/vue'

var DateComps = require("./DateSelectionComponent.js")
var DateSelectionComponent = DateComps.DateSelectionComponent

describe('date selection component', () => {
beforeEach(() => {
mount(DateSelectionComponent, {
propsData: {
defaultDate: "2021-06-09",
latestDate: "2021-12-31",
earliestDate: "2021-01-01"
}
})
})
it('sets to a default date', () => {
cy.get('[data-cy=date-select]')
.should('have.value', '2021-06-09')
})
it('allows selection of the date by the user', () => {
cy.get('[data-cy=date-select]')
.type('2021-08-02')
.should('have.value', '2021-08-02')
})
it('cannot be set to after latest date', () => {
cy.get('[data-cy=date-select]')
.type('2022-08-02')
.blur()
.should('have.value', '2021-12-31')
})
it('cannot be set to before earliest date', () => {
cy.get('[data-cy=date-select]')
.type('2010-08-02')
.blur()
.should('have.value', '2021-01-01')
})
it('emits date after input type date is blured', () => {
cy.get('[data-cy=date-select]')
.type('2010-08-02')
.blur().wrap('2010-08-02')
})
})

69 changes: 69 additions & 0 deletions farmdata2_modules/fd2_tabs/resources/customTableComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
let CustomTableComponent = {
template:`<div>
<table data-cy="custom-table" style="width:100%" border=1>
<tr>
<th data-cy="headers" v-for="header in headers">{{ header }}</th>
<th v-if="canEdit">Edit</th>
<th v-if="canDelete">Delete</th>
</tr>
<tr data-cy="objectTest" v-for="(row, index) in rows">
<td data-cy="tableData" v-for="(item, itemIndex) in row.data">
<input data-cy="testInput" v-if="rowsToEdit.includes(index)" v-model="row.data[itemIndex]"></input><p v-if="!rowsToEdit.includes(index)">{{ item }}</p>
</td>
<td v-if="canEdit">
<button data-cy="editButton" @click="editRow(index)" v-if="!rowsToEdit.includes(index)">Edit</button>
<button data-cy="saveButton" v-if="rowsToEdit.includes(index)" @click="finishRowEdit(index, row.id)">Save</button>
</td>
<td v-if="canDelete">
<button data-cy="deleteButton" @click="deleteRow(row.id)">Delete</button>
</td>
</tr>
</table>
</div>`,
props: {
rows: {
type: Array,
required: true
},
headers: {
type: Array,
required: true
},
canEdit: {
type: Boolean,
default: false
},
canDelete: {
type: Boolean,
default: false
}
},
data() {
return {
rowsToEdit: [],
}
},
methods: {
editRow: function(index){
this.rowsToEdit.push(index)
},
finishRowEdit: function(index, idToChange){
for(var i = 0; i < this.rowsToEdit.length; i++){
if(this.rowsToEdit[i] == index){
this.rowsToEdit.splice(i, 1)
}
}
var row = this.rows.filter(obj => {
return obj.id === idToChange
})
this.$emit('finished-row-edit', row)
},
deleteRow: function(id){
this.$emit('delete-row', id)
}
},
}
try{
module.exports = CustomTableComponent
}
catch(err) {}
Loading