Commit e40a765a authored by Karel Slaný's avatar Karel Slaný
Browse files

Merge branch 'pdz-info-qml' into 'develop'

Allow to Set Pefered Commercial Message Payment Method

Closes #217

See merge request !274
parents d3c28e97 9d3d707c
......@@ -229,7 +229,7 @@ SOURCES += \
src/worker/task_import_zfo.cpp \
src/worker/task_keep_alive.cpp \
src/worker/task_pdz_info.cpp \
src/worker/task_pdz_send_info.cpp \
src/worker/task_recipient_info.cpp \
src/worker/task_records_management_stored_messages.cpp \
src/worker/task_send_message.cpp \
src/worker/task_send_sms.cpp \
......@@ -398,7 +398,7 @@ HEADERS += \
src/worker/task_import_zfo.h \
src/worker/task_keep_alive.h \
src/worker/task_pdz_info.h \
src/worker/task_pdz_send_info.h \
src/worker/task_recipient_info.h \
src/worker/task_records_management_stored_messages.h \
src/worker/task_send_message.h \
src/worker/task_send_sms.h \
......
......@@ -29,9 +29,9 @@ import cz.nic.mobileDatovka.modelEntries 1.0
ScrollableListView {
id: root
delegateHeight: listItemHeight
/* These properties must be set by caller. */
property bool isSendMsgRecipList: false
property bool canDetailBoxes: false // enables viewing of box details
property bool canSelectBoxes: false // enables selecting of entries
property bool canDeselectBoxes: false // enables deselecting of entries
......@@ -44,6 +44,28 @@ ScrollableListView {
signal boxSelect(string boxId)
signal boxDeselect(string boxId)
signal boxRemove(string boxId)
signal pdzDmType(string boxId, int dmType)
delegateHeight: (isSendMsgRecipList) ? listItemHeight * 1.3 : listItemHeight
function descrDmType(dmType) {
switch (dmType) {
case 86: // 'V'
return qsTr("Public");
case 79: // 'O'
return qsTr("Response to initiatory");
case 71: // 'G'
return qsTr("Subsidised");
case 75: // 'K'
return qsTr("Contractual");
case 73: // 'I'
return qsTr("Initiatory");
case 69: // 'E'
return qsTr("Prepaid credit");
default:
return "N/A";
}
}
delegate: Rectangle {
id: dbItem
......@@ -51,115 +73,189 @@ ScrollableListView {
width: root.width
color: rDbSelected ? selectedItemBgColor : datovkaPalette.base
ColumnLayout {
id: databoxColumn
anchors.fill: parent
anchors.margins: defaultMargin
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
Text {
id: boxOwnerName
Layout.preferredWidth: parent.width - nextNavElement.width
elide: Text.ElideRight
text: rDbName
color: textHighlightColor
font.bold: true
}
Text {
id: boxOwnerAddress
Layout.preferredWidth: parent.width - nextNavElement.width
elide: Text.ElideRight
color: datovkaPalette.text
text: rDbAddress
}
Text {
id: boxInfo
font.pointSize: textFontSizeSmall
color: imageDarkerColor
text: if (rDbIc != "" && rDbType != "") {
"ID: " + rDbID + " (" + rDbType + ") IČO: " + rDbIc + " " + rDbSendOption
} else if (rDbIc == "" && rDbType != "") {
"ID: " + rDbID + " (" + rDbType + ")" + " " + rDbSendOption
} else if (rDbIc != "" && rDbType == "") {
"ID: " + rDbID + " IČO: " + rDbIc + " " + rDbSendOption
} else {
"ID: " + rDbID + " " + rDbSendOption
spacing: 0
Item {
Layout.fillWidth: true
Layout.preferredHeight: (isSendMsgRecipList) ? delegateHeight * 0.6 : delegateHeight
Column {
anchors.fill: parent
spacing: defaultMargin
Row {
spacing: defaultMargin
width: parent.width
Image {
id: warningIcon
visible: (isSendMsgRecipList && (rPdz === -1))
sourceSize.height: pictogramDimension
anchors.verticalCenter: parent.verticalCenter
source: "qrc:/ui/danger-cross-red.svg"
}
Text {
id: boxOwnerName
width: parent.width - nextNavElement.width
elide: Text.ElideRight
text: rDbName
color: textHighlightColor
font.bold: true
}
}
}
} // ColumnLayout
MouseArea {
/*
* Returns specified value:
* -1 - none ov below
* 0 - show box detail
* 1 - deselect box
* 2 - select box
*/
function actionOnClick() {
var ret = -1;
if (canDetailBoxes && !(canSelectBoxes || canDeselectBoxes)) {
ret = 0;
} else if (!canDetailBoxes && (canSelectBoxes || canDeselectBoxes)) {
if (rDbSelected && canDeselectBoxes) {
ret = 1;
} else if (!rDbSelected && canSelectBoxes) {
ret = 2;
Text {
id: boxOwnerAddress
width: parent.width - nextNavElement.width
elide: Text.ElideRight
color: datovkaPalette.text
text: rDbAddress
}
Text {
id: boxInfo
font.pointSize: textFontSizeSmall
color: imageDarkerColor
text: if (rDbIc != "" && rDbType != "") {
"ID: " + rDbID + " (" + rDbType + ") IČO: " + rDbIc + " " + rDbSendOption
} else if (rDbIc == "" && rDbType != "") {
"ID: " + rDbID + " (" + rDbType + ")" + " " + rDbSendOption
} else if (rDbIc != "" && rDbType == "") {
"ID: " + rDbID + " IČO: " + rDbIc + " " + rDbSendOption
} else {
"ID: " + rDbID + " " + rDbSendOption
}
}
} // Column
MouseArea {
/*
* Returns specified value:
* -1 - none ov below
* 0 - show box detail
* 1 - deselect box
* 2 - select box
*/
function actionOnClick() {
var ret = -1;
if (canDetailBoxes && !(canSelectBoxes || canDeselectBoxes)) {
ret = 0;
} else if (!canDetailBoxes && (canSelectBoxes || canDeselectBoxes)) {
if (rDbSelected && canDeselectBoxes) {
ret = 1;
} else if (!rDbSelected && canSelectBoxes) {
ret = 2;
}
}
return ret;
}
}
return ret;
}
/* Construct string to be presented to accessibility interface. */
function accessibleText() {
var aText = "";
switch (actionOnClick()) {
case 0:
aText += qsTr("View details about data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 1:
aText += qsTr("Deselect data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 2:
aText += qsTr("Select data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
default:
break;
}
/* Construct string to be presented to accessibility interface. */
function accessibleText() {
var aText = "";
return aText;
}
switch (actionOnClick()) {
case 0:
aText += qsTr("View details about data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 1:
aText += qsTr("Deselect data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 2:
aText += qsTr("Select data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
default:
break;
}
function handleClick() {
switch (actionOnClick()) {
case 0:
root.boxDetail(rDbID)
break;
case 1:
root.boxDeselect(rDbID)
break;
case 2:
root.boxSelect(rDbID)
break;
default:
break;
}
}
return aText;
}
anchors.fill: parent
function handleClick() {
switch (actionOnClick()) {
case 0:
root.boxDetail(rDbID)
break;
case 1:
root.boxDeselect(rDbID)
break;
case 2:
root.boxSelect(rDbID)
break;
default:
break;
}
}
Accessible.role: Accessible.Button
Accessible.name: accessibleText()
Accessible.onScrollDownAction: {
root.scrollDown()
}
Accessible.onScrollUpAction: {
root.scrollUp()
}
Accessible.onPressAction: {
handleClick()
}
onClicked: {
handleClick()
anchors.fill: parent
Accessible.role: Accessible.Button
Accessible.name: accessibleText()
Accessible.onScrollDownAction: {
root.scrollDown()
}
Accessible.onScrollUpAction: {
root.scrollUp()
}
Accessible.onPressAction: {
handleClick()
}
onClicked: {
handleClick()
}
}
} // Item
Item {
visible: isSendMsgRecipList
Layout.fillWidth: true
Layout.preferredHeight: delegateHeight * 0.3
Row {
anchors.fill: parent
spacing: defaultMargin
Text {
function setMessageTypeText(msgType) {
if (msgType === 0) {
return qsTr("Public")
} else if (msgType === 1) {
return qsTr("PDZ")
} else {
return qsTr("Unknown")
}
}
color: imageDarkerColor
font.pointSize: textFontSizeSmall
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Message type: %1").arg(setMessageTypeText(rPdz))
}
Text {
visible: (rPdz === 1 && rPdzDmTypeList.length === 1)
color: imageDarkerColor
font.pointSize: textFontSizeSmall
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Payment: %1").arg(descrDmType(rPdzDmTypeList[0]))
}
Text {
visible: (rPdz === 1 && rPdzDmTypeList.length > 1)
color: imageDarkerColor
font.pointSize: textFontSizeSmall
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Payment:")
}
AccessibleComboBox {
id: pdzPayments
visible: (rPdz === 1 && rPdzDmTypeList.length > 1)
z: 1
width: textFontSizeInPixels * 10
height: parent.height
accessibleDescription: qsTr("Select commercial message payment method.")
font.pointSize: textFontSizeSmall
anchors.verticalCenter: parent.verticalCenter
model: ListModel {
id: pdzPaymentsModel
}
Component.onCompleted: {
for (var i = 0; i<rPdzDmTypeList.length; i++ ) {
pdzPaymentsModel.append({label:descrDmType(rPdzDmTypeList[i]),key:rPdzDmTypeList[i]})
}
}
onCurrentIndexChanged: root.pdzDmType(rDbID, currentKey())
}
}
}
}
NextOverlaidImage {
......
......@@ -42,7 +42,7 @@ Item {
property var recipBoxModel: null
Component.onCompleted: {
var currentBoxId = accounts.boxId(acntId)
var currentBoxId = accounts.dbId(acntId)
messages.fillContactList(foundBoxModel, acntId, currentBoxId)
if (foundBoxModel.rowCount() === 0) {
emptyList.visible = true
......@@ -118,10 +118,10 @@ Item {
canDeselectBoxes: recipBoxModel != null
localContactFormat: true
onBoxSelect: {
var boxEntry = foundBoxModel.entry(boxId)
if (recipBoxModel != null) {
var boxEntry = foundBoxModel.entry(boxId)
foundBoxModel.selectEntry(boxEntry.dbID, true)
recipBoxModel.addEntry(boxEntry)
isds.addRecipient(acntId, boxEntry.dbID, boxEntry.dbName, boxEntry.dbAddress, false, recipBoxModel)
}
}
onBoxDeselect: {
......
......@@ -277,10 +277,10 @@ Item {
canSelectBoxes: recipBoxModel != null
canDeselectBoxes: recipBoxModel != null
onBoxSelect: {
var boxEntry = foundBoxModel.entry(boxId)
if (recipBoxModel != null) {
var boxEntry = foundBoxModel.entry(boxId)
foundBoxModel.selectEntry(boxEntry.dbID, true)
recipBoxModel.addEntry(boxEntry)
isds.addRecipient(acntId, boxEntry.dbID, boxEntry.dbName, boxEntry.dbAddress, false, recipBoxModel)
}
}
onBoxDeselect: {
......
......@@ -55,6 +55,7 @@ Item {
property string text_COLOR_RED: "#ff0000"
property bool iOS: false
property bool boxOVM: false
/* This property holds total attachment size in bytes */
property int totalAttachmentSizeBytes: 0
......@@ -62,9 +63,6 @@ Item {
/* This property holds navigation arrows dimension of tabbar */
property int tabNavImageDimension: imageNavigateDimension * 0.5
/* This property holds message type for sending. */
property string dmType: ""
/* Return file name from file path */
function getFileNameFromPath(filePath) {
return filePath.replace(/^.*[\\\/]/, '')
......@@ -114,28 +112,26 @@ Item {
function setReplyData(acntId, msgId) {
headerBar.title = qsTr("Reply %1").arg(msgId)
// get some message envelope data and add recipient to recipient model
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId, recipBoxModel)
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId)
dmAnnotation.text = "Re: " + isdsEnvelope.dmAnnotation
// swap sender ref and ident data to recipient (reply)
dmSenderRefNumber.text = isdsEnvelope.dmRecipientRefNumber
dmSenderIdent.text = isdsEnvelope.dmRecipientIdent
dmRecipientRefNumber.text = isdsEnvelope.dmSenderRefNumber
dmRecipientIdent.text = isdsEnvelope.dmSenderIdent
if (isdsEnvelope.dmType === "I") {
replyPDZ.visible = true
dmType = "O"
} else {
replyPDZ.visible = false
dmType = ""
}
setMandate(isdsEnvelope)
var canUseInitReply = false
if (isdsEnvelope.dmType === "I" || isdsEnvelope.dmType === "A") {
canUseInitReply = true
}
isds.addRecipient(acntId, isdsEnvelope.dbIDSender, isdsEnvelope.dmSender, isdsEnvelope.dmSenderAddress, canUseInitReply, recipBoxModel);
}
/* Set message envelope data and files to attachment model*/
function setTemplateData(acntId, msgId) {
headerBar.title = qsTr("Forward %1").arg(msgId)
// get some message envelope data, recipient model must be null (no recipient)
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId, null)
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId)
dmAnnotation.text = isdsEnvelope.dmAnnotation
dmSenderRefNumber.text = isdsEnvelope.dmSenderRefNumber
dmSenderIdent.text = isdsEnvelope.dmSenderIdent
......@@ -150,7 +146,7 @@ Item {
/* Set message forward data and add ZFO file to model */
function setForwardZfoData(acntId, msgId) {
headerBar.title = qsTr("Forward ZFO %1").arg(msgId)
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId, null)
var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(acntId, msgId)
dmAnnotation.text = "Fwd: " + isdsEnvelope.dmAnnotation
var fileName = (msgType == MessageType.TYPE_SENT) ? "ODZ_" + msgId + ".zfo" : "DDZ_" + msgId + ".zfo"
var zfoSize = zfo.getZfoSizeFromDb(acntId, msgId)
......@@ -194,23 +190,21 @@ Item {
Component.onCompleted: {
iOS = iOSHelper.isIos()
initPDZ.visible = false
initPDZ.checked = false
replyPDZ.visible = false
replyPDZ.checked = false
var boxEffectiveOVM = accounts.boxEffectiveOVM(acntId)
dmOVM.visible = boxEffectiveOVM
dmAllowSubstDelivery.visible = boxEffectiveOVM
boxOVM = accounts.isOvm(acntId)
var dbID = accounts.dbId(acntId);
var dbType = accounts.dbType(acntId);
databoxInfo.text = qsTr("Databox: %1 (%2)").arg(dbID).arg(dbType)
dmAllowSubstDelivery.visible = boxOVM
isds.doIsdsAction("initSendMsgDlg", acntId);
if (action === "new") {
initPDZ.visible = !boxEffectiveOVM
headerBar.title = qsTr("New message")
} else if (action === "reply") {
setReplyData(acntId, msgId)
} else if (action === "template") {
initPDZ.visible = !boxEffectiveOVM
setTemplateData(acntId, msgId)
} else if (action == "fwdzfo") {
initPDZ.visible = !boxEffectiveOVM
setForwardZfoData(acntId, msgId)
}
}
......@@ -358,8 +352,8 @@ Item {
dmLegalTitlePoint.text.toString(), dmToHands.text.toString(),
dmRecipientRefNumber.text.toString(), dmRecipientIdent.text.toString(),
dmSenderRefNumber.text.toString(), dmSenderIdent.text.toString(),
dmOVM.checked, dmPublishOwnID.checked, dmAllowSubstDelivery.checked,
dmPersonalDelivery.checked, dmType)
false, dmPublishOwnID.checked, dmAllowSubstDelivery.checked,
dmPersonalDelivery.checked)
}
}
......@@ -473,6 +467,11 @@ Item {
AccessibleText {
text: acntName + " (" + acntId.username + ")"
}
AccessibleText {
id: databoxInfo
width: parent.width
wrapMode: Text.Wrap
}
Text {
text: " "
}
......@@ -485,7 +484,7 @@ Item {
width: parent.width
height: inputItemHeight
font.pointSize: defaultTextFont.font.pointSize
placeholderText: qsTr("Enter subject")
placeholderText: qsTr("Enter subject. Mandatory")
InputLineMenu {
id: subjectMenu
inputTextControl: dmAnnotation
......@@ -500,12 +499,14 @@ Item {
}
AccessibleSwitch {
id: dmPublishOwnID
width: parent.width
text: qsTr("Include sender identification")
font.pointSize: defaultTextFont.font.pointSize
checked: true
}
AccessibleSwitch {
id: dmPersonalDelivery
width: parent.width
text: qsTr("Personal delivery")
font.pointSize: defaultTextFont.font.pointSize
checked: false
......@@ -513,37 +514,11 @@ Item {
AccessibleSwitch {
id: dmAllowSubstDelivery
visible: false
width: parent.width
text: qsTr("Allow acceptance through fiction")
font.pointSize: defaultTextFont.font.pointSize
checked: true
}
AccessibleSwitch {
id: dmOVM
visible: false
text: qsTr("Send as OVM")
font.pointSize: defaultTextFont.font.pointSize
checked: true
}
AccessibleSwitch {
id: initPDZ
visible: false
text: qsTr("Pay transfer charges for reply")
font.pointSize: defaultTextFont.font.pointSize
checked: false
onClicked: {
(initPDZ.checked) ? dmType = "I" : dmType = ""
}
}
AccessibleSwitch {
id: replyPDZ
visible: false
text: qsTr("Use transfer charges from recipient")
font.pointSize: defaultTextFont.font.pointSize
checked: false
onClicked: {
(replyPDZ.checked) ? dmType = "O" : dmType = ""
}
}
} // Column
} // Pane
} // Flickable
......@@ -594,11 +569,34 @@ Item {
width: parent.width
height: 600
model: recipBoxModel
isSendMsgRecipList: true
canRemoveBoxes: true
localContactFormat: true
onBoxRemove: {
recipBoxModel.removeEntry(boxId)
}
onPdzDmType: {
recipBoxModel.setPdzDmType(boxId, dmType)
/* Commercial message is initiatory - dmType 73. */
if (dmType === 73) {
/* Sender reference number must be filled. */
if (dmSenderRefNumber.text === "") {
tabBar.setCurrentIndex(3)
dmSenderRefNumberLabel.color = "red"
dmSenderRefNumber.placeholderText = qsTr("Mandatory for initiatory message")
dmSenderRefNumber.forceActiveFocus()
}
/* Commercial message is reply on initiatory - dmType 79. */
} else if (dmType === 79) {
/* Recipient reference number must be filled. */
if (dmRecipientRefNumber.text === "") {
tabBar.setCurrentIndex(3)
dmRecipientRefNumberLabel.color = "red"
dmRecipientRefNumber.placeholderText = qsTr("Mandatory for reply message")
dmRecipientRefNumber.forceActiveFocus()
}
}
}
} // DataboxList
}
//----ATTACHMENT SECTION------------
......@@ -847,6 +845,7 @@ Item {
}
//---Our ref.number---------------------
AccessibleText {
id: dmSenderRefNumberLabel
font.bold: true
text: qsTr("Our reference number")
}
......@@ -893,6 +892,7 @@ Item {
}