Commit 2f79be7b authored by Adrien PARROT's avatar Adrien PARROT
Browse files

Create conceptDetailPage, change icons (users icon, back navigation)

parent 681a8c50
......@@ -20,12 +20,12 @@ sap.ui.jsview("conceptmapper.CSVPage", {
*/
createContent : function(oController) {
var oSubHeader = new sap.m.Bar({
contentLeft : [ new sap.m.Button({
icon : "sap-icon://nav-back",
press : function(oEvt) {
app.back();
}
}) ],
// contentLeft : [ new sap.m.Button({
// icon : "sap-icon://nav-back",
// press : function(oEvt) {
// app.back();
// }
// }) ],
contentMiddle : [ new sap.m.Label({
text : "Upload CSV"
}) ]
......@@ -38,11 +38,22 @@ sap.ui.jsview("conceptmapper.CSVPage", {
var oPage = new sap.m.Page({
title : "{i18n>app_head}",
showNavButton: true, //peut etre que c'est mieux de le mettre ici
navButtonPress : function(oEvt) {
app.back();
},
showSubHeader : true,
subHeader : oSubHeader,
headerContent : [
new sap.m.Button({
// text:"lol",
icon:"sap-icon://account"
})
],
content : [ oUpload, oButton ]
});
return oPage;
}
......
sap.ui.controller("conceptmapper.conceptDetailPage", {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf conceptmapper.conceptDetailPage
*/
// onInit: function() {
//
// },
/**
* Similar to onAfterRendering, but this hook is invoked before the controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf conceptmapper.conceptDetailPage
*/
// onBeforeRendering: function() {
//
// },
/**
* Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being rendered.
* @memberOf conceptmapper.conceptDetailPage
*/
// onAfterRendering: function() {
//
// },
/**
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
* @memberOf conceptmapper.conceptDetailPage
*/
// onExit: function() {
//
// }
});
\ No newline at end of file
sap.ui.jsview("conceptmapper.conceptDetailPage", {
/** Specifies the Controller belonging to this View.
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
* @memberOf conceptmapper.conceptDetailPage
*/
getControllerName : function() {
return "conceptmapper.conceptDetailPage";
},
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
* Since the Controller is given to this method, its event handlers can be attached right away.
* @memberOf conceptmapper.conceptDetailPage
*/
createContent : function(oController) {
var oSubHeader = new sap.m.Bar({
contentLeft : [ new sap.m.Button({
icon : "sap-icon://nav-back",
press : function(oEvt) {
app.back();
}
}) ],
contentMiddle : [ new sap.m.Label({
text : "{label>/concept_name}"
}) ]
});
// var flexBox = new sap.m.FlexBox({
// alignItems: "Start",
// justifyContent: "SpaceBetween"
// })
var oAttrsConcept = [ new sap.m.ObjectAttribute({
title: "concept_id",
text : "{label>/concept_id}",
active : true,
press : function() {
alert("you press me");
}
}), new sap.m.ObjectAttribute({
title : "concept_name",
text : "{label>/concept_name}",
active : true,
press : function() {
oAttrs[0].setText("yolo");
}
}), new sap.m.ObjectAttribute({
title: "concept_code",
text : "{label>/concept_code}",
}), new sap.m.ObjectAttribute({
title: "concept_class_id",
text : "{label>/concept_class_id}",
active : true,
}), new sap.m.ObjectAttribute({
title: "vocabulary_id",
text : "{label>/concept_name}",
}), new sap.m.ObjectAttribute({
title: "domain_id",
text : "{label>/concept_name}",
title: "validity",
}), new sap.m.ObjectAttribute({
text : "{label>/concept_name}",
title: "standard_concept",
}),
];
var oConceptPanelHeader = new sap.m.ObjectHeader("oh2", {
//title : "Responsive ObjectHeader with attributes",
//number : "3.628.000",
//numberUnit : "EUR",
responsive: true,
attributes : oAttrsConcept
});
var oAttrsRelations = [ new sap.m.ObjectAttribute({
title: "Some title",
text : "Contract #D1234567890 Ñagçyfox",
active : true,
press : function() {
oAttrs2[0].setText("Ñagçyfox #D1234567890 Contract");
}
}), new sap.m.ObjectAttribute({
text : "John Doe Ñagçyfox",
active : true,
press : function() {
oAttrs2[0].setText("Ñagçyfox Contract #D1234567890");
}
}), new sap.m.ObjectAttribute({
title: "Custom content",
customContent: new sap.m.Link ({
text:"test",
press: function() {alert("you press me")}
})
}), new sap.m.ObjectAttribute({
text : "John Doe Ñagçyfox"
}), new sap.m.ObjectAttribute({
title: "Created by",
text : "John Doe Ñagçyfox"
}) ];
var oRelationsPanelHeader = new sap.m.ObjectHeader("oh3", {
title : "Relations!!!!",
//number : "3.628.000",
//numberUnit : "EUR",
responsive: true,
attributes : oAttrsRelations
});
var oConceptPanel = new sap.m.Panel("oConceptPanel_conceptDetail", {
expandable : true,
expanded : true,
headerText : "Concept details",
content : [
oConceptPanelHeader
]});
var oContentPanel = new sap.m.Panel("panel6", {
expandable : false,
expanded : true,
headerText : "Relations table",
content : [
oRelationsPanelHeader
]});
var oPage = new sap.m.Page({
title : "{i18n>app_head}",
showSubHeader : true,
subHeader : oSubHeader,
headerContent : [
new sap.m.Button({
// text:"lol",
icon:"sap-icon://home"
}),
new sap.m.Button({
// text:"lol",
icon:"sap-icon://account"
})
],
content : [ oConceptPanel, oContentPanel ]
});
return oPage;
}
});
\ No newline at end of file
......@@ -52,6 +52,12 @@ sap.ui.jsview("conceptmapper.homePage", {
var oPage = new sap.m.Page({
title : "{i18n>app_head}",
enableScrolling : false,
headerContent : [
new sap.m.Button({
// text:"lol",
icon:"sap-icon://account"
})
],
content : [ oTileCont ]
});
......
......@@ -76,6 +76,383 @@ sap.ui.controller("conceptmapper.searchPage", {
sap.ui.getCore().setModel(oModel, "vocabulary");
},
goToConceptDetail : function (oEvt) {
var sVal = oEvt.getParameters().rowBindingContext.getProperty('concept_id');
if (sVal !== undefined) {
var oData = {
"concept_id": oEvt.getParameters().rowBindingContext.getProperty('concept_id'),
"concept_name": oEvt.getParameters().rowBindingContext.getProperty('concept_name'),
"concept_code": oEvt.getParameters().rowBindingContext.getProperty('concept_code'),
"concept_class_id": oEvt.getParameters().rowBindingContext.getProperty('concept_class_id'),
"vocabulary_id": oEvt.getParameters().rowBindingContext.getProperty('vocabulary_id'),
"domain_id": oEvt.getParameters().rowBindingContext.getProperty('domain_id'),
"validity": oEvt.getParameters().rowBindingContext.getProperty('validity'),
"standard_concept": oEvt.getParameters().rowBindingContext.getProperty('standard_concept'),
};
sap.ui.getCore().setModel(new sap.ui.model.json.JSONModel(oData), "label");
}
app.to('idConceptDetailPage');
},
/******* CREATE *******/
openCreateDialog : function (oEvt) {
var oCreateDialog = new sap.m.Dialog({
title : "{i18n>create_concept}",
icon : "sap-icon://doc-attachment"
});
// ariaDescribedBy: "p1",
// state: sap.ui.core.ValueState.Warning,
var oSimpleForm = new sap.ui.layout.form.SimpleForm({
// maxContainerCols : 2,
content : [ new sap.m.Title({
text : "Concept"
}), new sap.m.Label({
text : "{i18n>concept_id}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>concept_name}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>concept_code}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>concept_class_id}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>vocabulary_id}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>domain_id}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>validity}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>standard_concept}"
}), new sap.ui.commons.TextField({
value : ""
}),
]
});
oCreateDialog.addContent(oSimpleForm);
oCreateDialog.addButton(
new sap.m.Button({
text: "Submit",
icon: "sap-icon://accept",
press: function () {
var content = oSimpleForm.getContent();
var oData = {};
oData.concept_id = content[2].getValue();
oData.concept_name = content[4].getValue();
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.validity = content[14].getValue();
oData.standard_concept = content[16].getValue();
if (oData.concept_id !== "" && oData.concept_name !== ""
&& oData.concept_code && oData.concept_class_id && oData.vocabulary_id
&& oData.domain_id && oData.validity && oData.standard_concept ) {
//
var oModel = sap.ui.getCore().getModel('concept');
var aData = oModel.getProperty("/names");
aData.push(oData);
oModel.setProperty("/names", aData);
// $.ajax({
// type:"POST",
// 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('concept');
// var aData = oModel.getProperty("/names");
// aData.push(oData);
// oModel.setProperty("/names", aData);
//
// // backend creation
// sap.m.MessageToast.show("New concept : '" + oData.concept_name + "' created");
// console.log("connection");
// },
// error : function(error) {
//
//
// sap.m.MessageToast.show("Connexion error");
// console.log(error);
// }
// });
} else {
sap.m.MessageToast.show("Nothing created!! \nYou have to file all the fields");
}
oCreateDialog.close();
}
})
);
oCreateDialog.addButton(
new sap.m.Button({
text: "Reject",
icon: "sap-icon://decline",
press: function () {
oCreateDialog.close();
}
})
);
oCreateDialog.open();
},
/******* UPDATE *******/
openUpdateDialog : function(oEvt) {
var button_press = oEvt.getParameters().id;
var oTable_ref = sap.ui.getCore().byId(button_press).getParent().getParent();
idx = oTable_ref.getSelectedIndices();
if (idx.length === 0) {
sap.m.MessageToast.show("Nobody to update");
return;
} else if (idx.length > 1) {
sap.m.MessageToast.show("You can update one concept each time");
return;
}
var concept = oTable_ref.getRows()[idx[0]].getCells();
debugger;
var oUpdateDialog = new sap.m.Dialog({
title : "{i18n>update_concept}",
icon : "sap-icon://doc-attachment"
});
var oSimpleForm = new sap.ui.layout.form.SimpleForm({
// maxContainerCols : 2,
content : [ new sap.m.Title({
text : "Concept"
}), new sap.m.Label({
text : "{i18n>concept_id}"
}), new sap.ui.commons.TextField({
enabled: false,
value : concept[0].getProperty('text')
}), new sap.m.Label({
text : "{i18n>concept_name}"
}), new sap.ui.commons.TextField({
value : concept[1].getProperty('text')
}), new sap.m.Label({
text : "{i18n>concept_code}"
}), new sap.ui.commons.TextField({
value : concept[2].getProperty('text')
}), new sap.m.Label({
text : "{i18n>concept_class_id}"
}), new sap.ui.commons.TextField({
value : concept[3].getProperty('text')
}), new sap.m.Label({
text : "{i18n>vocabulary_id}"
}), new sap.ui.commons.TextField({
value : concept[4].getProperty('text')
}), new sap.m.Label({
text : "{i18n>domain_id}"
}), 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>standard_concept}"
}), new sap.ui.commons.TextField({
value : concept[7].getProperty('text')
}),
]
});
oUpdateDialog.addContent(oSimpleForm);
oUpdateDialog.addButton(
new sap.m.Button({
text: "Submit",
icon: "sap-icon://accept",
press: function () {
var content = oSimpleForm.getContent();
var oData = {};
oData.concept_id = content[2].getValue();
oData.concept_name = content[4].getValue();
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.validity = content[14].getValue();
oData.standard_concept = 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('concept');
// 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);
// }
// });
oUpdateDialog.close();
}
})
);
oUpdateDialog.addButton(
new sap.m.Button({
text: "Reject",
icon: "sap-icon://decline",
press: function () {
oUpdateDialog.close();
}
})
);
oUpdateDialog.open();
},
/******* DELETE *******/
openDeleteDialog : function (oEvt) {
var button_press = oEvt.getParameters().id;
var oTable_ref = sap.ui.getCore().byId(button_press).getParent().getParent();
idx = oTable_ref.getSelectedIndices();
if (idx.length === 0) {
sap.m.MessageToast.show("Nobody to delete");
return;
} else if (idx.length > 1) {
sap.m.MessageToast.show("You can delete on concept each time");
return;
}
var oDeleteDialog = new sap.m.Dialog({
title : "{i18n>delete_concept}",
icon : "sap-icon://doc-attachment"
});
oDeleteDialog.addContent(new sap.m.Text({text: "You will suppress the select concept. Are you sure?"}));
oDeleteDialog.addButton(
new sap.m.Button({
text: "Delete",
type: "Reject",
icon: "sap-icon://accept",
press: function () {
var oModel = sap.ui.getCore().getModel('concept');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1);
oModel.setProperty("/names", aData);
// var URL = "http://127.0.0.1:5000/concept/";
// URL = URL + oTable_ref.getRows()[idx[0]].getCells()[0].getProperty('text');
// $.ajax({
// type:"DELETE",
// url:URL,
// dataType:"json",
// async: false,
// header: {
// "Content-Type": "application/json",