Commit 84c9ef98 authored by Internship UKSW 2019's avatar Internship UKSW 2019

Initial commit

parent 25eae3f3
......@@ -19,6 +19,8 @@ export class DataTableMyDocument extends Component {
{ title: "Status" },
{ title: "Tracking" },
{ title: "Creator" },
{ title: ""},
{ title: ""},
{ title: "Withdraw", width: 50 }
],
columnDefs: [
......
......@@ -308,28 +308,46 @@ class FormApprover extends Component {
})
if (dataReferences != undefined) {
for (let i = 0; i < dataReferences.length; i++) {
if (dataReferences[i].subject[0] != this.state.subjectEdit) {
let datarow = [];
let content = "";
let apiContent = "contentkey";
if (dataReferences[i].doc_code[0].includes("FORM")) {
apiContent = "contentkey2";
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/' + apiContent + '/' + dataReferences[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && dataReferences[i].doc_type[0] != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
content += "<p>" + dataContent[j].cont_title[0] + "</p>" + dataContent[j].cont[0];
}
}
if (dataContent != undefined && dataReferences[i].doc_type[0] == "FORM") {
content = "<p>" + dataContent[0].cont_title[0] + "</p>";
}
let checked = false;
datarow.push(dataReferences[i].doc_code[0]);
datarow.push(dataReferences[i].subject[0]);
datarow.push(dataReferences[i].doc_type[0]);
datarow.push(dataReferences[i].usr_dpt[0]);
for (let j = 0; j < this.state.selectReferences.length; j++) {
if (this.state.selectReferences[j] == (dataReferences[i].subject[0])) {
if (this.state.selectReferences[j] == (dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0])) {
checked = true;
break;
}
}
if (checked) {
datarow.push(dataReferences[i].subject[0] + " true");
datarow.push(dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0] + " true");
} else {
datarow.push(dataReferences[i].subject[0] + " false");
datarow.push(dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0] + " false");
}
datarow.push(content);
datarow.push(dataReferences[i].user_id[0]);
this.state.dataReferences.push(datarow);
}
}
}
tableScope = $('#tableScope').DataTable({
scrollY: "250px",
scrollCollapse: true,
......@@ -432,6 +450,20 @@ class FormApprover extends Component {
render: function (data, type, row) {
return "<input type='checkbox' name='listReference[]' " + ((data.includes("true")) ? "checked" : "") + " value='" + data + "'/>";
}
},
{
visible: false,
orderable: false,
targets: 5,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 6
}
]
})
......@@ -439,10 +471,10 @@ class FormApprover extends Component {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
if (e.target.checked) {
self.state.copyReferences.push(data[1]);
self.state.copyReferences.push(data[0] + " - " + data[1]);
self.state.validAddReference = true;
} else {
let i = self.state.copyReferences.indexOf(data[1]);
let i = self.state.copyReferences.indexOf(data[0] + " - " + data[1]);
self.state.copyReferences.splice(i, 1);
if (self.state.copyReferences.length == 0) {
self.state.validAddReference = false;
......@@ -453,7 +485,7 @@ class FormApprover extends Component {
tableReference.on("click", "a", function (e) {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1] + "&userid=" + data[6], "_blank");
})
}
} catch (err) {
......@@ -712,12 +744,22 @@ class FormApprover extends Component {
parseString(responseDataCheckSubject.data, function (err, result) {
dataCheckSubject = result.documentCollection.document;
})
if (dataCheckSubject != undefined && dataCheckSubject[0].doc_code[0].includes(this.state.businessUnit)) {
if (dataCheckSubject != undefined) {
let isAlreadyExist = false;
for (let i = 0; i < dataCheckSubject.length; i++) {
if (dataCheckSubject[i].doc_code[0].includes(this.state.businessUnit)) {
isAlreadyExist = true;
clonePage[index] = true;
alert("Document with same subject is already exist in your department!");
} else {
break;
}
}
if (isAlreadyExist == false) {
clonePage[index + 1] = true;
}
} else {
alert("There is no data document for subject " + this.state.subject);
}
} catch (err) {
clonePage[index] = true;
alert(err + "");
......@@ -1535,15 +1577,6 @@ class FormApprover extends Component {
this.setState({ isTableReferenceDraw: true });
}
}
handleAddCode = (subject) => {
let code;
for (var i = 0; i < this.state.dataReferences.length; i++) {
if (this.state.dataReferences[i][1] == subject) {
code = this.state.dataReferences[i][0];
}
}
return code;
}
//fungsi halaman add reference
handleSubmitReference = async () => {
this.changePageReference();
......@@ -3099,8 +3132,7 @@ class FormApprover extends Component {
<table className="my-table table table-striped table-hover" id="tableShowReference" >
<thead>
<tr>
<th className="col-xl-6 col-lg-9 col-md-9 col-sm-9">Subject <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2">Code</th>
<th className="col-xl-11 col-lg-11 col-md-11 col-sm-11">Code Document <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-1 col-lg-1 col-md-1 col-sm-1" style={{ width: "50px" }}>#</th>
</tr>
</thead>
......@@ -3110,7 +3142,6 @@ class FormApprover extends Component {
return (
<tr key={index}>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{reference}</a></td>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{this.handleAddCode(reference)}</a></td>
<td><input type="checkbox" name="listShowReference[]" value={reference}
onChange={(e) => this.handleSelectReference(e)} /></td>
</tr>
......@@ -3138,9 +3169,7 @@ class FormApprover extends Component {
}
</div>
<div hidden={!this.state.pageReference}>
<div className="form-group">
<table className="display" width="100%" id="tableReference"></table>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12 text-right">
<Button color="danger" onClick={() => this.changePageReference()}>&nbsp;Cancel&nbsp;</Button> &nbsp;&nbsp;
......
......@@ -89,7 +89,7 @@ class FormCreate extends Component {
datarow.push(dataReferences[i].subject[0]);
datarow.push(dataReferences[i].doc_type[0]);
datarow.push(dataReferences[i].usr_dpt[0]);
datarow.push(dataReferences[i].subject[0]);
datarow.push(dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0]);
datarow.push(content);
datarow.push(dataReferences[i].user_id[0]);
this.state.dataReferences.push(datarow);
......@@ -287,9 +287,19 @@ class FormCreate extends Component {
parseString(responseDataCheckSubject.data, function (err, result) {
dataCheckSubject = result.documentCollection.document;
})
if (dataCheckSubject != undefined && dataCheckSubject[0].doc_code[0].includes(this.state.businessUnit)) {
if (dataCheckSubject != undefined) {
let isAlreadyExist = false;
for (let i = 0; i < dataCheckSubject.length; i++) {
if (dataCheckSubject[i].doc_code[0].includes(this.state.businessUnit)) {
isAlreadyExist = true;
clonePage[index] = true;
alert("Document with same subject is already exist in your department!");
break;
}
}
if (isAlreadyExist == false) {
clonePage[index + 1] = true;
}
} else {
clonePage[index + 1] = true;
}
......@@ -608,15 +618,6 @@ class FormCreate extends Component {
this.setState({ isTableReferenceDraw: true });
}
}
handleAddCode = (subject) => {
let code;
for (var i = 0; i < this.state.dataReferences.length; i++) {
if (this.state.dataReferences[i][1] == subject) {
code = this.state.dataReferences[i][0];
}
}
return code;
}
//fungsi halaman add reference
handleSubmitReference = async () => {
this.changePageReference();
......@@ -766,10 +767,16 @@ class FormCreate extends Component {
body: JSON.stringify(postdataDokumen)
})
//Get Data Document By Subject
let dataDocument;
let responseDataDocument = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/document/' + this.state.subject, { headers: { 'accept': 'application/xml' } })
parseString(responseDataDocument.data, function (err, result) {
doc_id = result.documentCollection.document[0].doc_id[0];
dataDocument = result.documentCollection.document;
})
for (let i = 0; i < dataDocument.length; i++) {
if (JSON.parse(localStorage.getItem("dataLogin")).user_id[0] == dataDocument[i].user_id[0]) {
doc_id = dataDocument[i].doc_id[0];
}
}
let dataRevision = {
"doc_id": doc_id,
"rev_code": this.state.revisionCode,
......@@ -1316,8 +1323,7 @@ class FormCreate extends Component {
<table className="my-table table table-striped table-hover" id="tableShowReference" >
<thead>
<tr>
<th className="col-xl-6 col-lg-9 col-md-9 col-sm-9">Subject <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2">Code</th>
<th className="col-xl-11 col-lg-11 col-md-11 col-sm-11">Code Document <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-1 col-lg-1 col-md-1 col-sm-1" style={{ width: "50px" }}>#</th>
</tr>
</thead>
......@@ -1327,7 +1333,6 @@ class FormCreate extends Component {
return (
<tr key={index}>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{reference}</a></td>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{this.handleAddCode(reference)}</a></td>
<td><input type="checkbox" name="listShowReference[]" value={reference}
onChange={(e) => this.handleSelectReference(e)} /></td>
</tr>
......
......@@ -246,9 +246,9 @@ class FormRevision extends Component {
}
}
if (checked) {
datarow.push(dataDepartmentList[i].DepartmentCode[0] + "-" + dataDepartmentList[i].Department[0] + " true");
datarow.push(dataDepartmentList[i].DepartmentCode[0] + " - " + dataDepartmentList[i].Department[0] + " true");
} else {
datarow.push(dataDepartmentList[i].DepartmentCode[0] + "-" + dataDepartmentList[i].Department[0] + " false");
datarow.push(dataDepartmentList[i].DepartmentCode[0] + " - " + dataDepartmentList[i].Department[0] + " false");
}
this.state.dataScopes.push(datarow);
}
......@@ -259,28 +259,46 @@ class FormRevision extends Component {
})
if (dataReferences != undefined) {
for (let i = 0; i < dataReferences.length; i++) {
if (dataReferences[i].subject[0] != this.state.subjectEdit) {
let datarow = [];
let content = "";
let apiContent = "contentkey";
if (dataReferences[i].doc_code[0].includes("FORM")) {
apiContent = "contentkey2";
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/' + apiContent + '/' + dataReferences[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && dataReferences[i].doc_type[0] != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
content += "<p>" + dataContent[j].cont_title[0] + "</p>" + dataContent[j].cont[0];
}
}
if (dataContent != undefined && dataReferences[i].doc_type[0] == "FORM") {
content = "<p>" + dataContent[0].cont_title[0] + "</p>";
}
let checked = false;
datarow.push(dataReferences[i].doc_code[0]);
datarow.push(dataReferences[i].subject[0]);
datarow.push(dataReferences[i].doc_type[0]);
datarow.push(dataReferences[i].usr_dpt[0]);
for (let j = 0; j < this.state.selectReferences.length; j++) {
if (this.state.selectReferences[j] == (dataReferences[i].subject[0])) {
if (this.state.selectReferences[j] == (dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0])) {
checked = true;
break;
}
}
if (checked) {
datarow.push(dataReferences[i].subject[0] + " true");
datarow.push(dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0] + " true");
} else {
datarow.push(dataReferences[i].subject[0] + " false");
datarow.push(dataReferences[i].doc_code[0] + " - " + dataReferences[i].subject[0] + " false");
}
datarow.push(content);
datarow.push(dataReferences[i].user_id[0]);
this.state.dataReferences.push(datarow);
}
}
}
tableScope = $('#tableScope').DataTable({
scrollY: "250px",
scrollCollapse: true,
......@@ -383,6 +401,20 @@ class FormRevision extends Component {
render: function (data, type, row) {
return "<input type='checkbox' name='listReference[]' " + ((data.includes("true")) ? "checked" : "") + " value='" + data + "'/>";
}
},
{
visible: false,
orderable: false,
targets: 5,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 6
}
]
})
......@@ -390,10 +422,10 @@ class FormRevision extends Component {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
if (e.target.checked) {
self.state.copyReferences.push(data[1]);
self.state.copyReferences.push(data[0] + " - " + data[1]);
self.state.validAddReference = true;
} else {
let i = self.state.copyReferences.indexOf(data[1]);
let i = self.state.copyReferences.indexOf(data[0] + " - " + data[1]);
self.state.copyReferences.splice(i, 1);
if (self.state.copyReferences.length == 0) {
self.state.validAddReference = false;
......@@ -404,7 +436,7 @@ class FormRevision extends Component {
tableReference.on("click", "a", function (e) {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1] + "&userid=" + data[6], "_blank");
})
} catch (err) {
this.setState({ isFetched: true, fetchError: true });
......@@ -464,12 +496,22 @@ class FormRevision extends Component {
parseString(responseDataCheckSubject.data, function (err, result) {
dataCheckSubject = result.documentCollection.document;
})
if (dataCheckSubject != undefined && dataCheckSubject[0].doc_code[0].includes(this.state.businessUnit)) {
if (dataCheckSubject != undefined) {
let isAlreadyExist = false;
for (let i = 0; i < dataCheckSubject.length; i++) {
if (dataCheckSubject[i].doc_code[0].includes(this.state.businessUnit)) {
isAlreadyExist = true;
clonePage[index] = true;
alert("Document with same subject is already exist in your department!");
} else {
break;
}
}
if (isAlreadyExist == false) {
clonePage[index + 1] = true;
}
} else {
alert("There is no data document for subject " + this.state.subject);
}
} catch (err) {
clonePage[index] = true;
alert(err + "");
......@@ -894,15 +936,6 @@ class FormRevision extends Component {
this.setState({ isTableReferenceDraw: true });
}
}
handleAddCode = (subject) => {
let code;
for (var i = 0; i < this.state.dataReferences.length; i++) {
if (this.state.dataReferences[i][1] == subject) {
code = this.state.dataReferences[i][0];
}
}
return code;
}
//fungsi halaman add reference
handleSubmitReference = async () => {
this.changePageReference();
......@@ -2161,8 +2194,7 @@ class FormRevision extends Component {
<table className="my-table table table-striped table-hover" id="tableShowReference" >
<thead>
<tr>
<th className="col-xl-6 col-lg-9 col-md-9 col-sm-9">Subject <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2">Code</th>
<th className="col-xl-11 col-lg-11 col-md-11 col-sm-1">Code Document <img src="sorting-table.png" alt="sorting-table" height="14" width="12" onClick={() => this.sortTable("tableShowReference", 0)} /></th>
<th className="col-xl-1 col-lg-1 col-md-1 col-sm-1" style={{ width: "50px" }}>#</th>
</tr>
</thead>
......@@ -2172,7 +2204,6 @@ class FormRevision extends Component {
return (
<tr key={index}>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{reference}</a></td>
<td><a className="text-decoration-none text-dark" href="#" onClick={(e) => this.handleSelectReference2(e, reference)}>{this.handleAddCode(reference)}</a></td>
<td><input type="checkbox" name="listShowReference[]" value={reference}
onChange={(e) => this.handleSelectReference(e)} /></td>
</tr>
......@@ -2200,9 +2231,7 @@ class FormRevision extends Component {
}
</div>
<div hidden={!this.state.pageReference}>
<div className="form-group">
<table className="display" width="100%" id="tableReference"></table>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12 text-right">
<Button color="danger" onClick={() => this.changePageReference()}>&nbsp;Cancel&nbsp;</Button> &nbsp;&nbsp;
......
......@@ -21,7 +21,7 @@ class YourDocument extends Component {
}
}
componentDidMount = async () => {
try {
// try {
var parseString = require('xml2js').parseString;
let user_id = JSON.parse(localStorage.getItem("dataLogin")).user_id[0];
let responseDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/user', { headers: { 'accept': 'application/xml' } })
......@@ -63,7 +63,7 @@ class YourDocument extends Component {
datarow.push(dataAllDocument[i].doc_code[0]);
datarow.push(dataAllDocument[i].subject[0]);
datarow.push(dataAllDocument[i].doc_status[0]);
datarow.push(dataRevision[dataRevision.length - 1].status);
datarow.push(dataRevision[dataRevision.length-1].status);
datarow.push(JSON.parse(localStorage.getItem("dataLDAP"))["Full Name"]);
datarow.push(content);
datarow.push(dataAllDocument[i].user_id);
......@@ -182,10 +182,10 @@ class YourDocument extends Component {
}
}
await this.setState({ fetchStatus: true });
} catch (error) {
await this.setState({ fetchStatus: true, fetchError: true });
console.log(error + "");
}
// } catch (error) {
// await this.setState({ fetchStatus: true, fetchError: true });
// console.log(error + "");
// }
}
retryRetrievingData = (e) => {
e.preventDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment