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

Added generate report button and a mock report table #2

Merged
merged 5 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@ function fd2_barn_kit_menu() {
$items['farm/fd2-barn-kit/info'] = array(
'title' => 'Info',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -100,
'weight' => -10,
);

!
$items['farm/fd2-barn-kit/traySeedingReport'] = array(
'title' => 'Tray Seeding Report',
'page callback' => 'fd2_barn_kit_view',
'page arguments' => array('traySeedingReport.html'),
'access arguments' => array('view fd2 barn kit'),
'type' => MENU_LOCAL_TASK,
'weight' => -10,
);


return $items;
};

Expand Down
108 changes: 108 additions & 0 deletions farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<head>
<h1>Tray Seeding Report</h1>
</head>

<body>
<div id= "tray-seeding-report" v-cloak>
<label for = "cropList">Crop:</label>
<select id= "cropList" name = "simple" v-model="rptCrop">
<ul>
<option v-for="crop in crops">{{ crop }}</option>
</ul>
</select>
</div>
<br>

<div>
<label for="start">Start Date:</label>
<input type="date" id="start" name="start" v-model="reportStart" min="2014-01-01" :max="reportEnd">

<label for="end">End Date:</label>
<input type="date" id="end" name="end" v-model="reportEnd" :min="reportStart" max="2022-01-01">
</div>
<br>

<div>
<button class="btn btn-primary" @click="generateReport">Generate Report</button>
</div>

<div v-if="visible">
<hr />
<h2>Mock Report</h2>
<br>
<ul>
<li><strong>Start:</strong>{{}}</li>
<li><strong>End:</strong>{{}}</li>
<li><strong>Crop:</strong>{{}}</li>
</ul>

<br>
<table border=1>
<tr>
<th> Date of Seeding </th>
<th> Crop </th>
<th> Number of Seeds </th>
<th> Number of Trays </th>
<th> Cells per Tray </th>
<th> Variety </th>
<th> User </th>
<th> Comments </th>
</tr>

<tr>
<td>In Progress</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>

<script>
var databinding = new Vue({
el: '#tray-seeding-report',
data: {
crops: [],
rptCrop: "Kale",
reportStart: '2018-05-01',
reportEnd: '2018-07-31',
},
methods: {
timestampToYMD: function(timestamp) {
let d = this.timestampToDate(timestamp);
const month = d.getMonth() < 9 ?
'0' + (d.getMonth() + 1) :
d.getMonth() + 1;
const day = d.getDate() < 10 ?
'0' + d.getDate() :
d.getDate();
return d.getFullYear() + "-" + month + "-" + day;
},
generateReport: function() {
if(this.crops.length == 0) {
this.crops.push({rptCrop: 'Carrots', reportStart: '2018-05-01', reportEnd: '2018-07-31'});
}
else if(this.crops.length == 1) {
this.crops.push({rptCrop: 'Kale', reportStart: '2018-05-01', reportEnd: '2018-07-31'});
}
},
},
created() {
//let today = new Date.now();
//this.reportEnd = this.timestampToYMD(today);

axios.get('/farm_asset.json?type=planting').then(response => {
this.crops = response.data.list.map(f => f.name).sort();
});

let today = new Date.now();
this.reportEnd = this.timestampToYMD(today);
}
});
Vue.config.devtools = true;
</script>
</body>