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

Tiles in progress (Import CSV and user management)

parent 9af2eea3
sap.ui.controller("conceptmapper.CSVPage", {
/**
* 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.CSVPage
*/
// 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.CSVPage
*/
// 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.CSVPage
*/
// onAfterRendering: function() {
//
// },
/**
* Called when the Controller is destroyed. Use this one to free resources and finalize activities.
* @memberOf conceptmapper.CSVPage
*/
// onExit: function() {
//
// }
});
\ No newline at end of file
sap.ui.jsview("conceptmapper.CSVPage", {
/**
* 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.CSVPage
*/
getControllerName : function() {
return "conceptmapper.CSVPage";
},
/**
* 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.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();
}
}) ],
contentMiddle : [ new sap.m.Label({
text : "Upload CSV"
}) ]
});
var oUpload = new sap.ui.unified.FileUploader().addStyleClass("searchPage");
var oButton = new sap.m.Button({
text:"{i18n>CSV_upload}"
}).addStyleClass("searchPage");
var oPage = new sap.m.Page({
title : "{i18n>app_head}",
showSubHeader : true,
subHeader : oSubHeader,
content : [ oUpload, oButton ]
});
return oPage;
}
});
\ No newline at end of file
......@@ -37,6 +37,16 @@ sap.ui.controller("conceptmapper.homePage", {
app.to("idSearchPage");
},
goToUser: function(oEvt){
app.to("idUserPage");
},
goToCSV: function(oEvt){
app.to("idCSVPage");
},
/**
* 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.
......
......@@ -22,7 +22,7 @@ sap.ui.jsview("conceptmapper.homePage", {
// Common tiles
var oTileImportCSV = new sap.m.StandardTile({
title : "{i18n>tile_importCSV}",
// press:[oController.goToProductSearch,oController]
press:[oController.goToCSV,oController]
});
var oTileAlgos = new sap.m.StandardTile({
title : "{i18n>tile_algos}",
......@@ -40,7 +40,7 @@ sap.ui.jsview("conceptmapper.homePage", {
// Specifique admin tiles
var oTileUsers = new sap.m.StandardTile({
title : "{i18n>tile_users}",
// press:[oController.goToProductAnalytics,oController]
press:[oController.goToUser,oController]
});
var oTileCont = new sap.m.TileContainer({
......
sap.ui.controller("conceptmapper.userPage", {
/**
* 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.userPage
*/
onInit : function() {
var oData = {
"names" : [ {
username : "aparrot",
password : "toto",
firstname : "adrien",
lastname : "parrot",
address : "142",
email : "adrien.parrot@caramail.fr",
} , {
username : "mpondi",
password : "toto",
firstname : "marcy",
lastname : "pondi",
address : "142",
email : "marcy.pondi@caramail.fr",
} ]
};
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "user");
},
/******* CREATE *******/
openCreateDialog : function (oEvt) {
var oCreateDialog = new sap.m.Dialog({
title : "{i18n>create_user}",
icon : "sap-icon://employee"
});
// ariaDescribedBy: "p1",
// state: sap.ui.core.ValueState.Warning,
var oSimpleForm = new sap.ui.layout.form.SimpleForm({
// maxContainerCols : 2,
content : [ new sap.m.Title({
text : "Person"
}), new sap.m.Label({
text : "{i18n>username}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>password}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>firstname}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>lastname}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>address}"
}), new sap.ui.commons.TextField({
value : ""
}), new sap.m.Label({
text : "{i18n>email}"
}), 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.username = content[2].getValue();
oData.password = content[4].getValue();
oData.firstname = content[6].getValue();
oData.lastname = content[8].getValue();
oData.address = content[10].getValue();
oData.email = content[12].getValue();
if (oData.username !== "" && oData.password !== ""
&& oData.firstname && oData.lastname && oData.address && oData.email){
var oModel = sap.ui.getCore().getModel('user');
var aData = oModel.getProperty("/names");
aData.push(oData);
oModel.setProperty("/names", aData);
} 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 user each time");
return;
}
var user = oTable_ref.getRows()[idx[0]].getCells();
var oUpdateDialog = new sap.m.Dialog({
title : "{i18n>update_user}",
icon : "sap-icon://employee"
});
var oSimpleForm = new sap.ui.layout.form.SimpleForm({
// maxContainerCols : 2,
content : [ new sap.m.Title({
text : "Person"
}), new sap.m.Label({
text : "{i18n>username}"
}), new sap.ui.commons.TextField({
value : user[0].getProperty('text')
}), new sap.m.Label({
text : "{i18n>password}"
}), new sap.ui.commons.TextField({
value : user[1].getProperty('text')
}), new sap.m.Label({
text : "{i18n>firstname}"
}), new sap.ui.commons.TextField({
value : user[2].getProperty('text')
}), new sap.m.Label({
text : "{i18n>lastname}"
}), new sap.ui.commons.TextField({
value : user[3].getProperty('text')
}), new sap.m.Label({
text : "{i18n>address}"
}), new sap.ui.commons.TextField({
value : user[4].getProperty('text')
}), new sap.m.Label({
text : "{i18n>email}"
}), new sap.ui.commons.TextField({
value : user[5].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.username = content[2].getValue();
oData.password = content[4].getValue();
oData.firstname = content[6].getValue();
oData.lastname = content[8].getValue();
oData.address = content[10].getValue();
oData.email = content[12].getValue();
var oModel = sap.ui.getCore().getModel('user');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1, oData);
oModel.setProperty("/names", aData);
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 user each time");
return;
}
var oDeleteDialog = new sap.m.Dialog({
title : "{i18n>delete_user}",
icon : "sap-icon://employee"
});
oDeleteDialog.addContent(new sap.m.Text({text: "You will suppress the select user. 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('user');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1);
oModel.setProperty("/names", aData);
oDeleteDialog.close();
}
})
);
oDeleteDialog.addButton(
new sap.m.Button({
text: "Reject",
icon: "sap-icon://decline",
press: function () {
oDeleteDialog.close();
}
})
);
oDeleteDialog.open();
}
/**
* 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.userPage
*/
// 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.userPage
*/
// onAfterRendering: function() {
//
// },
/**
* Called when the Controller is destroyed. Use this one to free resources and
* finalize activities.
*
* @memberOf conceptmapper.userPage
*/
// onExit: function() {
//
// }
});
\ No newline at end of file
sap.ui.jsview("conceptmapper.userPage", {
/**
* 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.userPage
*/
getControllerName : function() {
return "conceptmapper.userPage";
},
/**
* 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.userPage
*/
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 : "{i18n>app_subhead_csv}"
}) ]
});
var oTable = new sap.ui.table.Table({
toolbar : new sap.m.Toolbar({
content : [ new sap.m.Button({
text : "{i18n>create_user}",
press : [ oController.openCreateDialog, oController ],
}), new sap.m.Button({
text : "{i18n>update_user}",
press : [ oController.openUpdateDialog, oController ],
}), new sap.m.Button({
text : "{i18n>delete_user}",
type : "Reject",
press : [ oController.openDeleteDialog, oController ],
}) ]
}),
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>username}"
}),
template : new sap.m.Text({
text : "{user>username}"
}),
editable : false,
sortProperty : "Username"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>password}"
}),
template : new sap.m.Text({
text : "{user>password}"
}),
editable : false,
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>firstname}"
}),
template : new sap.m.Text({
text : "{user>firstname}"
}),
sortProperty : "Firstname",
editable : false,
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>lastname}"
}),
template : new sap.m.Text({
text : "{user>lastname}"
}),
sortProperty : "Lastname",
editable : false,
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>address}"
}),
template : new sap.m.Text({
text : "{user>address}"
}),
sortProperty : "Address",
editable : false,
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "{i18n>email}"
}),
template : new sap.m.Text({
text : "{user>email}"
}),
sortProperty : "Email",
editable : false,
}));
oTable.bindRows({
path : "user>/names"
});
var oPage = new sap.m.Page({
title : "{i18n>app_head}",
showSubHeader : true,
subHeader : oSubHeader,
content : [ oTable ]
});
return oPage;
}
});
\ No newline at end of file
......@@ -5,4 +5,15 @@ tile_search=Concept Search
tile_map=Mapper
app_head=Concepts Mapper App
app_subhead_search=Search by id
search_placeholder=Search (id)
\ No newline at end of file
search_placeholder=Search (id)
app_subhead_csv=manage users (you can only select one user)
CSV_upload=Upload File
create_user=Create user
update_user=Update user's data
delete_user=Delete user
username=Username
password=Password
firtname=Firtname
lastname=Lastname
address=Address
email=Email
\ No newline at end of file
......@@ -5,4 +5,15 @@ tile_algos=Algorithmes
tile_search=Recherche
tile_map=Mapper
app_subhead_search=Recherche par id
search_placeholder=Recherche (id)
\ No newline at end of file
search_placeholder=Recherche (id)
app_subhead_csv=Utilisateurs (un seul utilisateur peut etre selectionne a la fois)
CSV_upload=Telechargement
create_user=Creation d'un utilisateur
update_user=Mise a jour d'un utilisateur
delete_user=Suppression d'un utilisateur
username=Username
password=Mot de passe
firstname=Prenom
lastname=Nom de famille
address=Adresse
email=email
\ No newline at end of file
......@@ -7,7 +7,7 @@
<script src="resources/sap-ui-core.js" id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m" data-sap-ui-theme="sap_bluecrystal">
data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table" data-sap-ui-theme="sap_bluecrystal">
</script>