Commit de00a677 authored by Adrien PARROT's avatar Adrien PARROT
Browse files

CRUD on searchPage ok

parent cf7f6f0f
......@@ -197,20 +197,20 @@ sap.ui.controller("conceptmapper.searchPage", {
text : "{i18n>domain_id}"
}), new sap.ui.commons.TextField({
value : ""
// }), new sap.m.Label({
// text : "{i18n>validity}"
// }), new sap.m.ComboBox({
// // width : "400px",
// //placeholder : "Standard Concepts",
// items : {
// path : "isValidModel>/items",
// template : oItemTemplateValid
// },
// selectedKeys : {
// path : "isValidModel>/selected",
// template : "{isValidModel>selected}"
// },
}), new sap.m.Label({
text : "{i18n>validity}"
}), new sap.m.ComboBox({
// width : "400px",
//placeholder : "Standard Concepts",
items : {
path : "isValidModel>/items",
template : oItemTemplateValid
},
selectedKeys : {
path : "isValidModel>/selected",
template : "{isValidModel>selected}"
},
}) , new sap.m.Label({
text : "{i18n>standard_concept}"
}), new sap.m.ComboBox({
// width : "400px",
......@@ -219,10 +219,6 @@ sap.ui.controller("conceptmapper.searchPage", {
path : "isStandardModel>/items",
template : oItemTemplateStandard
},
selectedKeys : {
path : "isStandardModel>/selected",
template : "{isStandardModel>selected}"
},
})
]
......@@ -246,12 +242,12 @@ sap.ui.controller("conceptmapper.searchPage", {
oData.concept_class_id = content[8].getValue();
oData.vocabulary_id = content[10].getValue();
oData.domain_id = content[12].getValue();
oData.invalid_reason = content[14].getValue();
oData.standard_concept = content[16].getValue();
//oData.invalid_reason = content[14].getValue();
oData.standard_concept = content[14].getValue();
if (oData.concept_id !== "" && Number.isInteger(parseInt(oData.concept_id)) && oData.concept_name !== ""
&& oData.concept_code !== "" && oData.concept_class_id !== "" && oData.vocabulary_id !== ""
&& oData.domain_id !== "" && oData.invalid_reason !== "" && oData.standard_concept !== "" ) {
&& oData.domain_id !== "" && oData.standard_concept !== "" ) {
var URL_concept = "http://127.0.0.1:5000/concept/";
// var URL_concept = "http://omop-mapper.fgh.ovh/concept/";
......@@ -291,6 +287,9 @@ sap.ui.controller("conceptmapper.searchPage", {
console.log(error);
}
});
} else if (!Number.isInteger(parseInt(oData.concept_id))) {
sap.m.MessageToast.show("concept_id shoulb be a number");
} else {
sap.m.MessageToast.show("Nothing created!! \nYou have to file all the fields");
}
......@@ -328,6 +327,7 @@ sap.ui.controller("conceptmapper.searchPage", {
return;
}
var concept = oTable_ref.getRows()[idx[0]].getCells();
debugger;
var oUpdateDialog = new sap.m.Dialog({
title : "{i18n>update_concept}",
......@@ -346,7 +346,7 @@ sap.ui.controller("conceptmapper.searchPage", {
}), new sap.m.Label({
text : "{i18n>concept_name}"
}), new sap.ui.commons.TextField({
value : concept[1].getProperty('text')
value : concept[1].getProperty('htmlText')
}), new sap.m.Label({
text : "{i18n>concept_code}"
}), new sap.ui.commons.TextField({
......@@ -359,21 +359,30 @@ sap.ui.controller("conceptmapper.searchPage", {
text : "{i18n>vocabulary_id}"
}), new sap.ui.commons.TextField({
value : concept[4].getProperty('text')
}), new sap.m.Label({
text : "{i18n>standard_concept}"
}), new sap.ui.commons.TextField({
value : concept[5].getProperty('text')
}), new sap.m.Label({
text : "{i18n>validity}"
}), new sap.ui.commons.TextField({
value : concept[6].getProperty('text')
}), new sap.m.Label({
text : "{i18n>domain_id}"
}), new sap.ui.commons.TextField({
value : concept[7].getProperty('text')
}),
// }), new sap.m.Label({
// text : "{i18n>validity}"
// }), new sap.ui.commons.TextField({
// value : concept[6].getProperty('text')
}), new sap.m.Label({
text : "{i18n>standard_concept}"
}), new sap.m.ComboBox({
// width : "400px",
//placeholder : "Standard Concepts",
items : {
path : "isStandardModel>/items",
template : oItemTemplateStandard
},
selectedKey : concept[5].getProperty('text'),
})
]
});
debugger;
oUpdateDialog.addContent(oSimpleForm);
......@@ -391,44 +400,50 @@ sap.ui.controller("conceptmapper.searchPage", {
oData.concept_code = content[6].getValue();
oData.concept_class_id = content[8].getValue();
oData.vocabulary_id = content[10].getValue();
oData.domain_id = content[12].getValue();
//oData.invalid_reason = content[14].getValue();
oData.standard_concept = content[14].getValue();
oData.standard_concept = content[12].getValue();
oData.invalid_reason = content[14].getValue();
oData.domain_id = content[16].getValue();
// var oModel = sap.ui.getCore().getModel('concept');
// var aData = oModel.getProperty("/names");
// aData.splice(idx[0], 1, oData);
// oModel.setProperty("/names", aData);
$.ajax({
type:"PUT",
url:"http://127.0.0.1:5000/concept/" + oData.concept_id,
dataType:"json",
data: oData,
async: false,
header: {
"Content-Type": "application/json",
},
success: function(data, response, xhr) {
// front update
var oModel = sap.ui.getCore().getModel('conceptsModel');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1, oData);
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New concept : '" + oData.concept_name + " 'updated");
console.log("connection");
},
error : function(error) {
sap.m.MessageToast.show("Connexion error");
console.log(error);
}
});
console.log(oData);
if ( oData.concept_name !== ""
&& oData.concept_code !== "" && oData.concept_class_id !== "" && oData.vocabulary_id !== ""
&& oData.domain_id !== "" && oData.standard_concept !== "" ) {
$.ajax({
type:"PUT",
url:"http://127.0.0.1:5000/concept/" + oData.concept_id,
dataType:"json",
data: oData,
async: false,
header: {
"Content-Type": "application/json",
},
success: function(data, response, xhr) {
// front update
oData.invalid_reason = 'Updated';
var oModel = sap.ui.getCore().getModel('conceptsModel');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1, oData);
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New concept : '" + oData.concept_name + " 'updated");
console.log("connection");
},
error : function(error) {
sap.m.MessageToast.show("Connexion error");
console.log(error);
}
});
} else if (!Number.isInteger(parseInt(oData.concept_id))) {
sap.m.MessageToast.show("concept_id shoulb be a number");
} else {
sap.m.MessageToast.show("Nothing created!! \nYou have to file all the fields");
}
oUpdateDialog.close();
......@@ -484,12 +499,12 @@ sap.ui.controller("conceptmapper.searchPage", {
var oData = {};
oData.concept_id = concept[0].getProperty('text');
oData.concept_name = concept[1].getProperty('text');
oData.concept_name = concept[1].getProperty('htmlText');
oData.concept_code = concept[2].getProperty('text');
oData.concept_class_id = concept[3].getProperty('text');
oData.vocabulary_id = concept[4].getProperty('text');
oData.standard_concept = concept[5].getProperty('text');
oData.invalid_reason = 'D';
oData.invalid_reason = 'Deleted';
oData.domain_id = concept[7].getProperty('text');
// var oModel = sap.ui.getCore().getModel('concept');
......
......@@ -165,7 +165,7 @@ sap.ui.controller("conceptmapper.userPage", {
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New user : '" + oData.username + "' created");
sap.m.MessageToast.show("New user : '" + oData.m_username + "' created");
console.log("connection");
},
error : function(error) {
......@@ -307,7 +307,7 @@ sap.ui.controller("conceptmapper.userPage", {
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New user : '" + oData.username + "' updated");
sap.m.MessageToast.show("New user : '" + oData.m_username + "' updated");
console.log("connection");
},
error : function(error) {
......
Supports Markdown
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