diff --git a/src/activities/server/components/AddModifyPupilDialog.qml b/src/activities/server/components/AddModifyPupilDialog.qml index 9a4c9e620..f25deec07 100644 --- a/src/activities/server/components/AddModifyPupilDialog.qml +++ b/src/activities/server/components/AddModifyPupilDialog.qml @@ -1,139 +1,187 @@ import QtQuick 2.6 import "../../../core" import QtQuick.Controls 2.12 import QtQuick.Layouts 1.2 import "../server.js" as Activity Popup { id: addModifyPupilDialog property string label: "To be modified in calling element." property string pupilName: "Pupil name to be modifyed in calling element." property string groupsNames: "Groups Names to be modifyed in calling element." property bool textInputReadOnly: false property int pupilsListIndex signal accepted() anchors.centerIn: Overlay.overlay width: 600 - height: 300 + height: 400 modal: true focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent ColumnLayout { + height: parent.height width: parent.width spacing: 20 + Text { + id: errorMessage + + Layout.preferredHeight: 40 + Layout.preferredWidth: errorMessage.implicitWidth + Layout.alignment : Qt.AlignHCenter | Qt.AlignCenter + + font { + family: Style.fontAwesome + pixelSize: 15 + + } + color: "red" + visible: false + } + Text { id: groupDialogText Layout.preferredHeight: 40 Layout.preferredWidth: parent.width Layout.leftMargin: 20 text: label font.bold: true font { family: Style.fontAwesome pixelSize: 20 } } Text { id: pupilNameTitleText Layout.preferredHeight: 20 Layout.preferredWidth: parent.width Layout.leftMargin: 40 text: qsTr("Pupil name") font.bold: true font { family: Style.fontAwesome pixelSize: 15 } } UnderlinedTextInput { id: pupilNameTextInput Layout.preferredHeight: 20 Layout.preferredWidth: parent.width Layout.leftMargin: 40 defaultText: addModifyPupilDialog.pupilName //? here we have a problem, when too long text is going left } Text { id: groupsListTitleText Layout.preferredHeight: 20 Layout.preferredWidth: parent.width Layout.leftMargin: 40 text: qsTr("Groups") font.bold: true font { family: Style.fontAwesome pixelSize: 15 } } UnderlinedTextInput { id: groupsNamesTextInput Layout.preferredHeight: 20 Layout.preferredWidth: parent.width Layout.leftMargin: 40 defaultText: addModifyPupilDialog.groupsNames } Rectangle { id: commandButtonsRectangle Layout.preferredWidth: parent.width Layout.fillHeight: true ViewButton { id: saveButton anchors.right: parent.right anchors.bottom: parent.bottom text: qsTr("Save") onClicked: { console.log("---- " + addModifyPupilDialog.pupilName) console.log("1++++---- " + pupilsListIndex) console.log("2++++---- " + pupilNameTextInput.text) console.log("3++++---- " + Activity.pupilsNamesArray) Activity.pupilsNamesArray[pupilsListIndex][0] = pupilNameTextInput.text - console.log("---- " + Activity.pupilsNamesArray) - - addModifyPupilDialog.accepted() - - - // addModifyPupilDialog.close(); + //Activity.pupilsNamesArray[pupilsListIndex][0] = pupilNameTextInput.text + + console.log("???? " + Activity.pupilsNamesArray[pupilsListIndex][2]) + + + + var testGroupNames = groupsNamesTextInput.text.split("-"); + //test if all the grousp added exist + var allGroupsAreValid = true + for (var i=0; i= 0; i--) { + if (pupilsDetailsRepeater.itemAt(i).pupilNameCheckBox.checked === true) { + Activity.pupilsNamesArray.splice(i,1) + + console.log("removed" + pupilsDetailsRepeater.itemAt(i).pupilNameCheckBox.text) + } + } + pupilsDetailsRepeater.model = Activity.pupilsNamesArray + } + } } diff --git a/src/core/serverMasterController/controllers/command-controller.cpp b/src/core/serverMasterController/controllers/command-controller.cpp index 1043891f0..71311b2ce 100644 --- a/src/core/serverMasterController/controllers/command-controller.cpp +++ b/src/core/serverMasterController/controllers/command-controller.cpp @@ -1,202 +1,203 @@ #include "command-controller.h" #include #include using namespace cm::framework; using namespace cm::models; namespace cm { namespace controllers { class CommandController::Implementation { public: Implementation(CommandController* _commandController, IDatabaseController* _databaseController, NavigationController* _navigationController, Client* _newClient, ClientSearch* _clientSearch) : commandController(_commandController) , databaseController(_databaseController) , navigationController(_navigationController) , newClient(_newClient) , clientSearch(_clientSearch) { Command* createClientSaveCommand = new Command( commandController, QChar( 0xf0c7 ), "Save" ); QObject::connect( createClientSaveCommand, &Command::executed, commandController, &CommandController::onCreateClientSaveExecuted ); createClientViewContextCommands.append( createClientSaveCommand ); Command* findClientSearchCommand = new Command( commandController, QChar( 0xf002 ), "Search" ); QObject::connect( findClientSearchCommand, &Command::executed, commandController, &CommandController::onFindClientSearchExecuted ); findClientViewContextCommands.append( findClientSearchCommand ); Command* editClientDeleteCommand = new Command( commandController, QChar( 0xf235 ), "Delete" ); QObject::connect( editClientDeleteCommand, &Command::executed, commandController, &CommandController::onEditClientDeleteExecuted ); editClientViewContextCommands.append( editClientDeleteCommand ); Command* editClientSaveCommand = new Command( commandController, QChar( 0xf0c7 ), "Save" ); QObject::connect( editClientSaveCommand, &Command::executed, commandController, &CommandController::onEditClientSaveExecuted ); editClientViewContextCommands.append( editClientSaveCommand ); Command* managePupilsAddPupilCommand = new Command( commandController, QChar( 0xf234 ), "Add Pupil" ); QObject::connect( managePupilsAddPupilCommand, &Command::executed, commandController, &CommandController::onManagePupilsAddPupilExecuted ); managePupilsViewContextCommands.append( managePupilsAddPupilCommand ); Command* managePupilsAddPupilFromListCommand = new Command( commandController, QChar( 0xf2c2 ), "Add Pupils from List" ); QObject::connect( managePupilsAddPupilFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsAddPupilsFromListExecuted ); managePupilsViewContextCommands.append( managePupilsAddPupilFromListCommand ); Command* managePupilsRemovePupilsFromListCommand = new Command( commandController, QChar( 0xf503 ), "Remove Pupil(s)" ); QObject::connect( managePupilsRemovePupilsFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsRemovePupilsExecuted ); managePupilsViewContextCommands.append( managePupilsRemovePupilsFromListCommand ); Command* managePupilsEditPupilFromListCommand = new Command( commandController, QChar( 0xf4ff ), "Edit Pupil" ); QObject::connect( managePupilsEditPupilFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsEditPupilExecuted ); managePupilsViewContextCommands.append( managePupilsEditPupilFromListCommand ); } CommandController* commandController{nullptr}; IDatabaseController* databaseController{nullptr}; NavigationController* navigationController{nullptr}; Client* newClient{nullptr}; ClientSearch* clientSearch{nullptr}; Client* selectedClient{nullptr}; QList createClientViewContextCommands{}; QList findClientViewContextCommands{}; QList editClientViewContextCommands{}; QList managePupilsViewContextCommands{}; }; CommandController::CommandController(QObject* parent, IDatabaseController* databaseController, NavigationController* navigationController, Client* newClient, ClientSearch* clientSearch) : QObject(parent) { implementation.reset(new Implementation(this, databaseController, navigationController, newClient, clientSearch)); } CommandController::~CommandController() { } QQmlListProperty CommandController::ui_createClientViewContextCommands() { return QQmlListProperty(this, implementation->createClientViewContextCommands); } QQmlListProperty CommandController::ui_findClientViewContextCommands() { return QQmlListProperty(this, implementation->findClientViewContextCommands); } QQmlListProperty CommandController::ui_editClientViewContextCommands() { return QQmlListProperty(this, implementation->editClientViewContextCommands); } QQmlListProperty CommandController::ui_managePupilsViewContextCommands() { return QQmlListProperty(this, implementation->managePupilsViewContextCommands); } void CommandController::setSelectedClient(Client* client) { implementation->selectedClient = client; } void CommandController::onCreateClientSaveExecuted() { qDebug() << "You executed the Save command!"; implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView(); } void CommandController::onFindClientSearchExecuted() { qDebug() << "You executed the Search command!"; implementation->clientSearch->search(); } void CommandController::onEditClientSaveExecuted() { qDebug() << "You executed the Save command!"; implementation->databaseController->updateRow(implementation->selectedClient->key(), implementation->selectedClient->id(), implementation->selectedClient->toJson()); qDebug() << "Updated client saved."; } void CommandController::onEditClientDeleteExecuted() { qDebug() << "You executed the Delete command!"; implementation->databaseController->deleteRow(implementation->selectedClient->key(), implementation->selectedClient->id()); implementation->selectedClient = nullptr; qDebug() << "Client deleted."; implementation->clientSearch->search(); implementation->navigationController->goAddPupilsFromListDialog(); } void CommandController::onManagePupilsAddPupilExecuted() { qDebug() << "You created a new pupil!"; + implementation->navigationController->goAddPupilDialog(); /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsAddPupilsFromListExecuted() { qDebug() << "You created new pupils from list!"; implementation->navigationController->goAddPupilsFromListDialog(); /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsEditPupilExecuted() { qDebug() << "You edited a pupil!"; /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsRemovePupilsExecuted() { qDebug() << "You removed pupil(s)!"; implementation->navigationController->goRemovePupilsDialog(); /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } }} diff --git a/src/core/serverMasterController/controllers/navigation-controller.h b/src/core/serverMasterController/controllers/navigation-controller.h index 4090e0b9c..19eb60006 100644 --- a/src/core/serverMasterController/controllers/navigation-controller.h +++ b/src/core/serverMasterController/controllers/navigation-controller.h @@ -1,34 +1,35 @@ #ifndef NAVIGATIONCONTROLLER_H #define NAVIGATIONCONTROLLER_H #include #include #include namespace cm { namespace controllers { class CMLIBSHARED_EXPORT NavigationController : public QObject { Q_OBJECT public: explicit NavigationController(QObject* parent = nullptr) : QObject(parent){} signals: void goManagePupilsView(); void goCreateClientView(); void goDashboardView(); void goEditClientView(cm::models::Client* client); void goFindClientView(); void goManageWorkPlanView(); void goAddPupilsFromListDialog(); void goRemovePupilsDialog(); + void goAddPupilDialog(); }; } } #endif