| 1 |
import QtQuick 2.4 |
| 2 |
import QtQuick.Controls 1.2 |
| 3 |
import QtQuick.Controls.Styles 1.2 |
| 4 |
import "../../../modules/windows" |
| 5 |
import "../../../components" |
| 6 |
import "../../../components/controlsstyles" |
| 7 |
import "../../../modules/tabs" |
| 8 |
import "../../../modules/sidepanel" |
| 9 |
import "../../../modules/workarea" |
| 10 |
import "../../../modules/contacts" |
| 11 |
import "../../../modules/rightside" as RightSide |
| 12 |
import "../../../modules/actionarea" |
| 13 |
import "../../../modules/DSListModel" |
| 14 |
import "../../../modules/DSListModel/DSFunctions.js" as DSFunctions |
| 15 |
import "../../../../scripts/SetProperty.js" as SetProperty |
| 16 |
import "../../../modules/rightside/rightSide.js" as RightSideJS |
| 17 |
import "../../../modules/rightside/rightSideData.js" as RSData |
| 18 |
import '../../../../scripts/Utils.js' as JSUtils |
| 19 |
import "../../../modules/contacts/utils.js" as ContactsUtils |
| 20 |
import "../../../modules/layout" |
| 21 |
Item { |
| 22 |
id: root |
| 23 |
objectName: "root" |
| 24 |
property QueryDialog p_actionDialog |
| 25 |
property LoaderWindow p_loaderWindow |
| 26 |
property Item p_centerSide |
| 27 |
property Item p_topSide |
| 28 |
property Item p_tooltip |
| 29 |
property Item p_launcher |
| 30 |
property Item p_dndArea |
| 31 |
property ListModel p_filterMenu: ListModel { |
| 32 |
property alias p_dataContactsList: dataContactsList |
| 33 |
property alias p_editContact: contactDetailsPersonal |
| 34 |
property alias p_internal: internal |
| 35 |
property variant p_newContactInfo |
| 36 |
property variant p_contactDB: root |
| 37 |
property variant t_record |
| 38 |
property variant p_dsObject |
| 39 |
property variant p_DNObject |
| 40 |
property variant p_DMObject |
| 41 |
property variant p_imageObj |
| 42 |
property variant p_phoneNumbers |
| 43 |
property variant p_visible: root.visible && ((root.parent.p_currentChild === 'personal.list') || (root.parent.p_currentChild === 'personal')) |
| 44 |
property variant p_handlerChangeImage |
| 45 |
property variant p_handlerUpdate |
| 46 |
property variant p_handlerCreate |
| 47 |
property variant p_handlerDuplicate |
| 48 |
property variant p_handlerDirectNumber |
| 49 |
property variant p_handlerDepartmentMembers |
| 50 |
property variant p_handlerToggleItem |
| 51 |
property variant p_handlerDelete |
| 52 |
property variant p_lastTab |
| 53 |
property variant p_dataSourceList: [ |
| 54 |
{ p_title: qsTr("Personal") + xroot.emptyString, p_list: dataContactsList, p_enable: true ]; |
| 55 |
property string p_child: "personal" |
| 56 |
property string p_main: "workarea" |
| 57 |
property string p_mainChild: "personal" |
| 58 |
property string p_currentChild: "personal" |
| 59 |
property string p_mode: "show_contact" |
| 60 |
property string p_phoneNumber: "" |
| 61 |
property string p_getRecordByID: "" |
| 62 |
property string p_url: "" |
| 63 |
property string p_selectID: "" |
| 64 |
property string p_selectIndex: "" |
| 65 |
property real p_hidePos: 0 |
| 66 |
property int p_currentIndex: -1 |
| 67 |
property int p_current: 0 |
| 68 |
property int p_duration: 300 |
| 69 |
property int p_nextInd: -1 |
| 70 |
property int p_gotoIndex: -1 |
| 71 |
property bool p_addPhoto: false |
| 72 |
property bool p_focus: false |
| 73 |
property bool p_isLoading: false |
| 74 |
property bool p_isAnimation: true |
| 75 |
property bool p_isRetina: false |
| 76 |
property bool p_updateContact: false |
| 77 |
property bool p_addToExisting: false |
| 78 |
property bool p_changed: false |
| 79 |
property bool p_editMode: contactDetailsPersonal.p_editMode || root.p_addContact |
| 80 |
property bool p_rightOpened: false |
| 81 |
property bool p_backClicked: false |
| 82 |
property bool p_addContact: false property variant p_infoModel: ListModel { |
| 83 |
property variant p_emailModel: ListModel { |
| 84 |
property variant p_phoneModel: ListModel { |
| 85 |
property variant p_adressModel: ListModel { |
| 86 |
property variant p_additionalModel: ListModel { |
| 87 |
visible: false |
| 88 |
signal iShowDialog(string method, string title, string msg) |
| 89 |
Keys.onEscapePressed: { |
| 90 |
xroot.log('Contacts Press onEscapePressed', 4) |
| 91 |
if (contactsTabs.p_rightOpened) { |
| 92 |
var _contactDetails = contactDetailsPersonal; |
| 93 |
if (p_addPhoto) { |
| 94 |
xroot.log('Contacts addPhoto ESC', 4) |
| 95 |
_contactDetails.item.aShowAddPhotoBox("", true); |
| 96 |
else if (p_updateContact) { |
| 97 |
xroot.log('Contacts updateContact ESC', 4) |
| 98 |
_contactDetails.item.aShowAddPhotoBox("", true); |
| 99 |
else { |
| 100 |
if (!_contactDetails.p_editMode) { |
| 101 |
_contactDetails.item.iClickedAction("", "", ""); |
| 102 |
_contactDetails.item.iShowDetailsAction(false); |
| 103 |
Keys.onPressed: { |
| 104 |
root.p_centerSide.aExecuteKeyboardSupport(event, false); |
| 105 |
onActiveFocusChanged: { |
| 106 |
if (activeFocus) { |
| 107 |
searchPanelContacts.forceActiveFocus(); |
| 108 |
onIShowDialog: { |
| 109 |
if (root.p_actionDialog !== null && root.p_actionDialog.p_currentAction !== 'cancel_' + method) { |
| 110 |
xroot.dialogIntf.postShowDialog( |
| 111 |
JSON.stringify( |
| 112 |
{ |
| 113 |
"id": 'cancel_' + method, |
| 114 |
"title": (title.length? title : ''), |
| 115 |
"msg": (msg.length? msg : qsTr('You have made the changes that will be lost if you terminate the edit process. Do you want to discard them?') + xroot.emptyString), |
| 116 |
"buttonList" : [ |
| 117 |
{ |
| 118 |
"buttonName" : "Cancel", |
| 119 |
"buttonText" : qsTr('Cancel') + xroot.emptyString, |
| 120 |
"buttonStyle" : "buttonStyleTwo" |
| 121 |
, |
| 122 |
{ |
| 123 |
"buttonName" : "Ok", |
| 124 |
"buttonText" : qsTr('Yes') + xroot.emptyString, |
| 125 |
"buttonStyle" : "buttonStyleThree" |
| 126 |
] |
| 127 |
) |
| 128 |
); |
| 129 |
onVisibleChanged: { |
| 130 |
filterArea.p_showAction = false |
| 131 |
if (!visible) { |
| 132 |
if (root.p_addContact || root.p_addPhoto || root.p_addToExisting || contactDetailsPersonal.p_editMode) { |
| 133 |
root.aGetDefault(); |
| 134 |
else { |
| 135 |
if(!p_visible) { |
| 136 |
ContactsUtils.aGetVisibleSource(root, dataContactsList, false) |
| 137 |
root.aGetDefault(); |
| 138 |
if (!root.p_isAnimation) { |
| 139 |
root.focusToSearch(); |
| 140 |
onP_visibleChanged: { |
| 141 |
if (!p_visible) { |
| 142 |
if(visible) { |
| 143 |
ContactsUtils.aGetVisibleSource(root, dataContactsList, false) |
| 144 |
if (root.p_addContact || root.p_addPhoto || root.p_addToExisting || contactDetailsPersonal.p_editMode) { |
| 145 |
root.aGetDefault(); |
| 146 |
onP_dsObjectChanged: { |
| 147 |
root.init() |
| 148 |
onWidthChanged: { |
| 149 |
root.aShowAddPhotoBox(root.p_mode, false) |
| 150 |
onP_backClickedChanged: { |
| 151 |
xroot.log("Contact backClicked " + p_backClicked, 4) |
| 152 |
onP_newContactInfoChanged: { |
| 153 |
if (p_newContactInfo !== undefined) { |
| 154 |
try { |
| 155 |
var jsonData = JSON.parse(p_newContactInfo); |
| 156 |
root.p_phoneNumber = xroot.formatNumberForUI(jsonData["p_phoneNumber"]); |
| 157 |
root.p_addToExisting = (jsonData["edit_contact"] === "1"); |
| 158 |
root.aClearSubscribe(); |
| 159 |
if (jsonData["add_contact"] === "1") { |
| 160 |
contactDetailsPersonal.iEditModeAction("add_contact", "onP_newContactInfoChanged") |
| 161 |
catch (e) { |
| 162 |
xroot.log("ERROR Contact WRONG JSON newContactInfo: "+e, 1) |
| 163 |
p_newContactInfo = undefined |
| 164 |
onP_currentChanged: { |
| 165 |
var _current = xroot.readDbSetting('lastTabContact') |
| 166 |
_current = (_current !== undefined? _current : -1) |
| 167 |
if (parseInt(_current) !== p_current |
| 168 |
&& p_current !== -1 |
| 169 |
&& !contactDetailsPersonal.p_editMode |
| 170 |
&& !root.p_addContact |
| 171 |
&& !root.p_addToExisting ) { |
| 172 |
xroot.log('xroot.writeDbSetting lastTabContact', 4); |
| 173 |
xroot.writeDbSetting('lastTabContact', p_current ) |
| 174 |
root.aGetVisibleModel(false) |
| 175 |
if (!root.p_isAnimation) { |
| 176 |
root.focusToSearch() |
| 177 |
onP_rightOpenedChanged: { |
| 178 |
root.aGetVisibleModel(root.p_rightOpened) |
| 179 |
onP_editModeChanged: { |
| 180 |
root.p_topSide.p_disabled = p_editMode |
| 181 |
xroot.emitSignal("Contacts.CenterSide.EditModeChanged", root.p_editMode); |
| 182 |
function aClearSearch() { |
| 183 |
searchPanelContacts.p_value = "" |
| 184 |
function aGetVisibleModel(flag) { |
| 185 |
ContactsUtils.aGetVisibleSource(dataContactsList, root, flag) |
| 186 |
function aGetDefault() { |
| 187 |
root.p_addPhoto = false; |
| 188 |
root.p_addContact = false; |
| 189 |
root.p_addToExisting = false; |
| 190 |
root.p_updateContact = false; |
| 191 |
root.p_phoneNumber = ""; |
| 192 |
root.p_changed = false; |
| 193 |
root.p_rightOpened = false; |
| 194 |
contactDetailsPersonal.iShowDetailsAction(false, "root_visible"); |
| 195 |
function focusToSearch() { |
| 196 |
if (root.visible && !searchPanelContacts.p_readOnly && !contactsTabs.p_rightOpened) { |
| 197 |
searchPanelContacts.setFocus() |
| 198 |
function aShowAddPhotoBox(mode, resize) { |
| 199 |
root.p_isAnimation = resize |
| 200 |
root.p_mode = mode |
| 201 |
function init0(dsObject, realObject) { |
| 202 |
realObject.p_imagePath = "" |
| 203 |
realObject.p_contactID = dsObject.hasField("id")? dsObject.field("id") :" 0" |
| 204 |
realObject.p_isFavorite = dsObject.hasField('hasFavorite')? parseInt(dsObject.field('hasFavorite')) : false; |
| 205 |
realObject.p_imagePath = dsObject.hasField('photoLink') && dsObject.field('photoLink').length? dsObject.field('photoLink') : "" |
| 206 |
realObject.p_countPhones = dsObject.hasField('phonesCount')? dsObject.field('phonesCount') : 0 |
| 207 |
if (realObject.sourceComponent === componentContactDetails && realObject.item.p_hiddenProperties) { |
| 208 |
realObject.item.p_hiddenProperties.aClear(); |
| 209 |
realObject.item.p_hiddenProperties.aFillIn(dsObject) |
| 210 |
function init() { xroot.log("CONTACT INIT GLOBAL", 4) |
| 211 |
var p_dsObject = root.p_dsObject |
| 212 |
if (p_dsObject && root.p_visible) { |
| 213 |
var i = 0, |
| 214 |
oldContactId = contactDetailsPersonal.p_contactID, |
| 215 |
t_emails = {; |
| 216 |
contactDetailsPersonal.p_contactID = "0" |
| 217 |
init0(p_dsObject, contactDetailsPersonal); |
| 218 |
contactDetailsPersonal.p_extStatus = "" |
| 219 |
if (p_dsObject.hasField('message')&&p_dsObject.field('message')!=="") { |
| 220 |
contactDetailsPersonal.p_extStatus = JSUtils.aGetPresenceStatusLabel(p_dsObject.field("message"), xroot); |
| 221 |
else { |
| 222 |
if (p_dsObject.hasField("presenceStatus") && p_dsObject.field("presenceStatus")) { |
| 223 |
contactDetailsPersonal.p_extStatus = JSUtils.aGetPresenceStatusLabel(p_dsObject.field("presenceStatus"), xroot); |
| 224 |
if (p_dsObject.hasField("hasPresence") && p_dsObject.field("hasPresence")) { |
| 225 |
contactDetailsPersonal.p_hasPresence = (p_dsObject.field("hasPresence") === "1") |
| 226 |
if (p_dsObject.hasField("isDepartment")) { |
| 227 |
contactDetailsPersonal.p_isDepartment = true; |
| 228 |
requestMembers.start() |
| 229 |
else { |
| 230 |
root.p_DMObject = [] |
| 231 |
contactDetailsPersonal.p_isDepartment = false; |
| 232 |
contactDetailsPersonal.p_isExt = false |
| 233 |
contactDetailsPersonal.p_isOutlook = false |
| 234 |
contactDetailsPersonal.p_isOsxContact = false |
| 235 |
if (p_dsObject.hasField('sourceTypeId')) { |
| 236 |
switch (p_dsObject.field('sourceTypeId')) { |
| 237 |
case "8": |
| 238 |
contactDetailsPersonal.p_isOutlook = true; |
| 239 |
break; |
| 240 |
case "4": |
| 241 |
contactDetailsPersonal.p_isOsxContact = true; |
| 242 |
break; |
| 243 |
case "2": |
| 244 |
contactDetailsPersonal.p_isExt = true; |
| 245 |
break; |
| 246 |
if (contactDetailsPersonal.p_isExt) { |
| 247 |
var p_status = JSUtils.getStatus(p_dsObject); |
| 248 |
contactDetailsPersonal.p_telephonyStatus = "" |
| 249 |
contactDetailsPersonal.p_telephonyStatus = p_status; |
| 250 |
var personalResult = ContactsUtils.parsePersonalInfo(p_dsObject, RSData.infoModel); |
| 251 |
root.p_infoModel = personalResult.model; |
| 252 |
contactDetailsPersonal.p_text = personalResult.name |
| 253 |
root.p_emailModel = ContactsUtils.parseEmails(p_dsObject, RSData.p_emailMap); |
| 254 |
internal.p_emailModel = ContactsUtils.parseEmails(p_dsObject, RSData.p_emailMap); |
| 255 |
if (p_dsObject.hasField("phones") /*&& root.p_phoneNumbers !== p_dsObject.field("phones")*/) { var phoneResult = ContactsUtils.parsePhones(p_dsObject, RSData.phoneModel, RSData.p_mapPhones, RightSideJS.aFillModelwith); |
| 256 |
root.p_phoneModel = phoneResult.model; |
| 257 |
root.p_phoneNumbers = phoneResult.phoneNumbers; |
| 258 |
internal.p_phoneModel = ContactsUtils.parsePhones(p_dsObject, RSData.phoneModel, RSData.p_mapPhones, RightSideJS.aFillModelwith).model; |
| 259 |
if(oldContactId !== contactDetailsPersonal.p_contactID) { |
| 260 |
root.p_DMObject = [] |
| 261 |
root.p_DNObject = [] |
| 262 |
if (p_dsObject.hasField("directNumbers")) { |
| 263 |
try { |
| 264 |
var _array = JSON.parse(p_dsObject.field("directNumbers")) |
| 265 |
if (root.p_DNObject !== _array) { |
| 266 |
root.p_DNObject = _array |
| 267 |
catch(e) { |
| 268 |
xroot.log("ERROR Contact WRONG JSON DN: "+e, 1) |
| 269 |
root.p_DNObject = [] |
| 270 |
var brandId = kvs.userInfo.p_object.hasField("brandCountryId")? kvs.userInfo.p_object.field("brandCountryId") : ""; |
| 271 |
root.p_adressModel = ContactsUtils.parseAddressInfo(p_dsObject, RSData.getAdressModel(brandId), RightSideJS.aFillModelwith); |
| 272 |
internal.p_adressModel = ContactsUtils.parseAddressInfo(p_dsObject, RSData.getAdressModel(brandId), RightSideJS.aFillModelwith); |
| 273 |
RightSideJS.aFillModelwith(RSData.additionalModel, root.p_additionalModel, p_dsObject, true, undefined) |
| 274 |
RightSideJS.aFillModelwith(RSData.additionalModel, internal.p_additionalModel, p_dsObject, true, undefined) |
| 275 |
xroot.log("CONTACT INIT END", 4); |
| 276 |
function aClearSubscribe() { |
| 277 |
if (dataContactsList.p_subscribeId.length && dataContactsList.p_masterRecord.hasAction('unsubscribeFromRecordTracking')) { |
| 278 |
dataContactsList.p_masterRecord.action('unsubscribeFromRecordTracking', dataContactsList.p_subscribeId) |
| 279 |
dataContactsList.p_subscribeId = "" |
| 280 |
Connections { |
| 281 |
target: xroot |
| 282 |
ignoreUnknownSignals: true |
| 283 |
onSignalEmitted: { |
| 284 |
var _name = name.split("."); |
| 285 |
var _subName = _name[1].split("_"); |
| 286 |
var _payload = payload.split("."); |
| 287 |
if (_name[0] === "FilterArea" && _subName[1] === "syncFilterSelected" && _payload[0] === "changeOptions") { |
| 288 |
filterArea.aSetFilterItem(dataContactsList) |
| 289 |
filterArea.aSetDataFilter(dataContactsList, 'contactType') |
| 290 |
if (dataContactsList.p_masterRecord !== undefined && dataContactsList.p_masterRecord !== null && dataContactsList.p_masterRecord.hasField("contactFilterTypeMenu")) { |
| 291 |
dataContactsList.p_contactFilterTypeMenu = dataContactsList.p_masterRecord.field("contactFilterTypeMenu") |
| 292 |
onCompleteAction: { |
| 293 |
switch (handler) { |
| 294 |
case filterArea.p_writeFilterTypeHandler: |
| 295 |
filterArea.p_writeFilterTypeHandler = undefined |
| 296 |
if (root.visible) { |
| 297 |
filterArea.aSetDataFilter(dataContactsList, 'contactType') |
| 298 |
xroot.emitSignal("FilterArea.broadcast_syncFilterSelected", "changeOptions.Contact"); |
| 299 |
break; |
| 300 |
case root.p_handlerUpdate: |
| 301 |
xroot.log("Contacts p_handlerUpdate " + desc, 4) |
| 302 |
root.p_handlerUpdate = undefined |
| 303 |
root.p_handlerChangeImage = undefined |
| 304 |
root.p_updateContact = true |
| 305 |
contactDetailsPersonal.p_editMode = false |
| 306 |
if (ok) { |
| 307 |
xroot.getDB(dataContactsList.p_db).requestRecordById(contactDetailsPersonal.p_contactID) |
| 308 |
contactDetailsPersonal.iEditModeAction("save", "handlerUpdate") |
| 309 |
break; |
| 310 |
case root.p_handlerCreate: |
| 311 |
xroot.log("Contacts p_handlerCreate " + desc, 4) |
| 312 |
root.p_handlerCreate = undefined |
| 313 |
RightSideJS.aClearModel(root) |
| 314 |
root.p_addContact = false |
| 315 |
contactDetailsPersonal.p_editMode = false |
| 316 |
root.aClearSubscribe(); |
| 317 |
dataContactsList.p_view.currentIndex = root.p_gotoIndex = parseInt(desc) - 1 |
| 318 |
if (dataContactsList.p_count + 1 >= parseInt(desc)) { |
| 319 |
contactDetailsPersonal.iEditModeAction("save", "handlerCreate") |
| 320 |
else { |
| 321 |
contactDetailsPersonal.iShowDetailsAction(false, "handlerCreate") |
| 322 |
break; |
| 323 |
case root.p_handlerDuplicate: |
| 324 |
xroot.log("Contacts p_handlerDuplicate " + desc, 4) |
| 325 |
root.p_handlerDuplicate = undefined |
| 326 |
root.aClearSubscribe(); |
| 327 |
dataContactsList.p_view.currentIndex = root.p_gotoIndex = parseInt(desc) - 1 |
| 328 |
contactDetailsPersonal.iFinishImportAction(); |
| 329 |
contactDetailsPersonal.iShowDetailsAction(false, "handlerCreate"); |
| 330 |
break; |
| 331 |
case root.p_handlerDirectNumber: |
| 332 |
xroot.log("GET DIRECT NUMBER: '"+desc+"'", 4) |
| 333 |
if (ok) { |
| 334 |
try { |
| 335 |
var _arrayDn = JSON.parse(desc) |
| 336 |
if (root.p_DNObject !== _arrayDn) { |
| 337 |
root.p_DNObject = _arrayDn |
| 338 |
catch(e) { |
| 339 |
xroot.log("ERROR Contacts p_handlerDirectNumber: "+e, 1) |
| 340 |
root.p_DNObject = [] |
| 341 |
root.p_handlerDirectNumber = undefined |
| 342 |
break; |
| 343 |
case root.p_handlerDepartmentMembers: |
| 344 |
xroot.log("p_handlerDepartmentMembers: '"+p_handlerDepartmentMembers+"' desc: "+desc+"' ok: "+ok, 4) |
| 345 |
if (ok) { |
| 346 |
requestMembers.stop(); |
| 347 |
try { |
| 348 |
var _arrayDm = JSON.parse(desc) |
| 349 |
if (root.p_DMObject !== _arrayDm) { |
| 350 |
root.p_DMObject = _arrayDm |
| 351 |
catch(e) { |
| 352 |
xroot.log("ERROR Contacts p_handlerDepartmentMembers: "+e, 1) |
| 353 |
root.p_DMObject = [] |
| 354 |
root.p_handlerDirectNumber = undefined |
| 355 |
break; |
| 356 |
case root.p_handlerDepartmentMembers: |
| 357 |
xroot.log("p_handlerDepartmentMembers: '"+p_handlerDepartmentMembers+"' desc: "+desc+"' ok: "+ok, 4) |
| 358 |
if (ok) { |
| 359 |
requestMembers.stop(); |
| 360 |
try { |
| 361 |
var _arrayDm = JSON.parse(desc) |
| 362 |
if (root.p_DMObject !== _arrayDm) { |
| 363 |
root.p_DMObject = _arrayDm |
| 364 |
catch(e) { |
| 365 |
xroot.log("ERROR Contacts p_handlerDepartmentMembers: "+e, 1) |
| 366 |
root.p_DMObject = [] |
| 367 |
root.p_handlerDepartmentMembers = undefined |
| 368 |
break; |
| 369 |
case root.p_handlerToggleItem: |
| 370 |
root.p_handlerToggleItem = undefined |
| 371 |
if (ok && root.visible) { |
| 372 |
if (contactDetailsPersonal.p_contactID !== "0") { |
| 373 |
xroot.getDB(dataContactsList.p_db).requestRecordById(contactDetailsPersonal.p_contactID) |
| 374 |
break; |
| 375 |
case root.p_handlerDelete: |
| 376 |
root.p_selectID = "" |
| 377 |
contactDetailsPersonal.iShowDetailsAction(true, "p_actionDialog_iAcceptedAction") |
| 378 |
contactDetailsPersonal.p_editMode= false |
| 379 |
root.p_isAnimation = false |
| 380 |
break; |
| 381 |
Connections { |
| 382 |
target: root.p_contactDB |
| 383 |
ignoreUnknownSignals: true |
| 384 |
onRecordByIdReady: { |
| 385 |
root.t_record = record; |
| 386 |
var _dsObject = xroot.extract(root.t_record); |
| 387 |
if (!_dsObject.hasField("requestRecordByIdFailed")) { |
| 388 |
root.p_dsObject = _dsObject |
| 389 |
root.p_isAnimation = true |
| 390 |
if (root.p_visible) { |
| 391 |
if (!root.p_addToExisting) { |
| 392 |
if (!root.p_backClicked) { |
| 393 |
contactDetailsPersonal.iShowDetailsAction(true, "p_contactDB_RecordByIdReady") |
| 394 |
root.p_backClicked = false |
| 395 |
else { |
| 396 |
contactDetailsPersonal.iEditModeAction("edit", "p_contactDB_RecordByIdReady") |
| 397 |
else { |
| 398 |
root.aClearSubscribe(); |
| 399 |
contactDetailsPersonal.iShowDetailsAction(false, "p_contactDB_RecordByIdReady") |
| 400 |
if (_dsObject.hasAction("getDirectNumbers") && kvs.featureSet.getProperty('isOffline') !== true) { |
| 401 |
xroot.log("GET DIRECT NUMBER", 4); |
| 402 |
root.p_handlerDirectNumber = _dsObject.action("getDirectNumbers"); |
| 403 |
onCompleteAction: { |
| 404 |
if (handler === root.p_searchHandler) { |
| 405 |
dataContactsList.sizeChange(); |
| 406 |
Connections { |
| 407 |
target: xroot.dialogIntf |
| 408 |
ignoreUnknownSignals: true |
| 409 |
onUiRequestedDialogClosed: { |
| 410 |
if (bName === "Ok") { |
| 411 |
switch(id) { |
| 412 |
case "delete_contact": |
| 413 |
contactDetailsPersonal.p_editMode = false; |
| 414 |
var delete_id = root.p_selectID.length? root.p_selectID : contactDetailsPersonal.p_contactID |
| 415 |
xroot.log("Delete Contact with id " + delete_id + " root.p_selectID " + root.p_selectID +" contactDetailsPersonal.p_contactID " + contactDetailsPersonal.p_contactID, 4) |
| 416 |
if (delete_id !== "0" && delete_id.length) { |
| 417 |
root.p_handlerDelete = xroot.deleteContact(delete_id); |
| 418 |
break; |
| 419 |
case "cancel_add_contact": |
| 420 |
case "cancel_edit_contact": |
| 421 |
contactDetailsPersonal.item.aCancelAction(); |
| 422 |
break; |
| 423 |
case "cancel_top_add_contact": |
| 424 |
case "cancel_top_edit_contact": |
| 425 |
contactDetailsPersonal.item.aCancelAction(); |
| 426 |
if (root.p_url.length) { |
| 427 |
root.p_centerSide.setDisplay(root.p_url) |
| 428 |
root.p_url = "" |
| 429 |
break; |
| 430 |
else if (bName === "Cancel") { |
| 431 |
Connections { |
| 432 |
target: p_actionDialog |
| 433 |
onICanceledAction: { onIOpacityChanged: { |
| 434 |
if (!opacity && !contactDetailsPersonal.p_editMode) { |
| 435 |
restartTimerFocus.restart() |
| 436 |
Connections { |
| 437 |
target: p_topSide |
| 438 |
onIGoToAction: { |
| 439 |
root.p_url = url |
| 440 |
var _current = (url === 'workarea.personal.list' || url === 'workarea.personal') |
| 441 |
if (p_topSide.p_disabled && root.p_visible && !_current) { |
| 442 |
if (root.p_addContact) { |
| 443 |
if (RightSideJS.aNotEmpty(root)) { |
| 444 |
root.iShowDialog("top_add_contact", "", "") |
| 445 |
else { |
| 446 |
root.p_centerSide.setDisplay(url) |
| 447 |
else { |
| 448 |
if (RightSideJS.aChanged(root, contactDetailsPersonal.item)) { |
| 449 |
root.iShowDialog("top_edit_contact", "", "") |
| 450 |
else { |
| 451 |
root.p_centerSide.setDisplay(url) |
| 452 |
id: internal |
| 453 |
property variant p_emailModel: ListModel { |
| 454 |
property variant p_phoneModel: ListModel { |
| 455 |
property variant p_adressModel: ListModel { |
| 456 |
property variant p_additionalModel: ListModel { |
| 457 |
ContextualMenu { |
| 458 |
id: editMenu |
| 459 |
objectName: "contactsEditMenu" |
| 460 |
property bool p_isExternal: false |
| 461 |
style: ContentMenuStyle { MenuItem { |
| 462 |
text: qsTr("Delete") + xroot.emptyString |
| 463 |
objectName: "delete" |
| 464 |
onTriggered : { |
| 465 |
xroot.dialogIntf.postShowDialog( |
| 466 |
JSON.stringify( |
| 467 |
{ |
| 468 |
"id": 'delete_contact', |
| 469 |
"title": "", |
| 470 |
"msg": qsTr('Delete selected contact?') + xroot.emptyString, |
| 471 |
"buttonList" : [ |
| 472 |
{ |
| 473 |
"buttonName" : "Cancel", |
| 474 |
"buttonText" : qsTr('Cancel') + xroot.emptyString, |
| 475 |
"buttonStyle" : "buttonStyleTwo" |
| 476 |
, |
| 477 |
{ |
| 478 |
"buttonName" : "Ok", |
| 479 |
"buttonText" : qsTr('Delete') + xroot.emptyString, |
| 480 |
"buttonStyle" : "buttonStyleThree" |
| 481 |
] |
| 482 |
) |
| 483 |
); |
| 484 |
enabled: !editMenu.p_isExternal && kvs.featureSet.getPermission('EditPersonalContacts') |
| 485 |
ListModel { |
| 486 |
id: iconsLogModel |
| 487 |
objectName: "iconsLogModel" |
| 488 |
ListElement { name: "NoCall"; label: QT_TR_NOOP("No Call"); icon: "presence/status/available.svg" ListElement { name: "CallConnected"; label: QT_TR_NOOP("Call Connected"); icon: "presence/status/not-disturb.svg" ListElement { name: "Ringing"; label: QT_TR_NOOP("Ringing"); icon: "presence/status/available.svg" ListElement { name: "Busy"; label: QT_TR_NOOP("Busy"); icon: "presence/status/not-disturb.svg" ListElement { name: "Offline"; label: QT_TR_NOOP("Invisible"); icon: "topbar/dnd/Invisible.svg" Component { |
| 489 |
id: emptyComponent |
| 490 |
Rectangle { |
| 491 |
anchors.fill: parent |
| 492 |
Text { |
| 493 |
id: textEmpty |
| 494 |
objectName: "textEmpty" |
| 495 |
antialiasing: true |
| 496 |
renderType: root.p_isRetina? Text.QtRendering : Text.NativeRendering |
| 497 |
text: qsTr("Please select one of the contacts from the list") + xroot.emptyString |
| 498 |
elide: Text.ElideRight |
| 499 |
anchors { |
| 500 |
verticalCenter: parent.verticalCenter |
| 501 |
left: parent.left |
| 502 |
right: parent.right |
| 503 |
leftMargin: 20 |
| 504 |
rightMargin: 20 |
| 505 |
horizontalAlignment: Text.AlignHCenter |
| 506 |
color: kvs.uiScheme.getStyleProperty("color28", 'transparent') |
| 507 |
font { |
| 508 |
family: kvs.uiScheme.getFont('normal') |
| 509 |
pixelSize: 14 |
| 510 |
MouseArea { |
| 511 |
anchors.fill: parent |
| 512 |
preventStealing: true |
| 513 |
hoverEnabled: true |
| 514 |
onExited: { |
| 515 |
if(root.p_tooltip) { |
| 516 |
root.p_tooltip.p_text = ""; |
| 517 |
onEntered: { |
| 518 |
if (root.p_tooltip && textEmpty.width < textEmpty.implicitWidth) { |
| 519 |
root.p_tooltip.p_text = textEmpty.text |
| 520 |
root.p_tooltip.p_tooltipX = mapToItem(null, 0.0, 0.0).x + mouseX |
| 521 |
root.p_tooltip.p_tooltipY = mapToItem(null, 0.0, 0.0).y + parent.height |
| 522 |
Component.onCompleted: { |
| 523 |
if (root.visible) { |
| 524 |
contactDetailsPersonal.iShowDetailsAction(false, "emptyComponentOnCompleted") |
| 525 |
MouseArea { |
| 526 |
anchors.fill: parent |
| 527 |
onClicked: { |
| 528 |
filterArea.p_showAction = false |
| 529 |
Component { |
| 530 |
id: componentContactDetails |
| 531 |
ContactDetails { |
| 532 |
id: contactDetailsInner |
| 533 |
objectName: "contactDetailsInner" |
| 534 |
anchors.fill: parent |
| 535 |
p_isRetina: root.p_isRetina |
| 536 |
p_tooltip: root.p_tooltip |
| 537 |
p_launcher: root.p_launcher |
| 538 |
p_isOutlook: contactDetailsInner.parent != null? contactDetailsInner.parent.p_isOutlook : false |
| 539 |
p_isOsxContact: contactDetailsInner.parent != null? contactDetailsInner.parent.p_isOsxContact : false |
| 540 |
p_hideShow: contactDetailsInner.parent != null? contactDetailsInner.parent.p_hideShow : true |
| 541 |
p_isFavorite: contactDetailsInner.parent != null? contactDetailsInner.parent.p_isFavorite : false |
| 542 |
p_imagePath: contactDetailsInner.parent != null? contactDetailsInner.parent.p_imagePath : "" |
| 543 |
p_text: contactDetailsInner.parent != null? contactDetailsInner.parent.p_text : "" |
| 544 |
p_contactID: contactDetailsInner.parent != null? contactDetailsInner.parent.p_contactID : "0" |
| 545 |
p_countPhones: contactDetailsInner.parent != null? contactDetailsInner.parent.p_countPhones : 0 |
| 546 |
p_listType: contactDetailsInner.parent != null && contactDetailsInner.parent.p_isExt? "company" : "personal" |
| 547 |
p_hasPresence: contactDetailsInner.parent != null && contactDetailsInner.parent.p_hasPresence !== undefined? contactDetailsInner.parent.p_hasPresence : "" |
| 548 |
p_isDepartment: contactDetailsInner.parent != null? contactDetailsInner.parent.p_isDepartment : false |
| 549 |
p_extStatus: contactDetailsInner.parent != null && contactDetailsInner.parent.p_extStatus !== undefined? contactDetailsInner.parent.p_extStatus : "" |
| 550 |
p_telephonyStatus: contactDetailsInner.parent != null && contactDetailsInner.parent.p_telephonyStatus !== undefined? contactDetailsInner.parent.p_telephonyStatus : "" |
| 551 |
p_infoModel: root.p_infoModel |
| 552 |
p_emailModel: root.p_emailModel |
| 553 |
p_phoneModel: root.p_phoneModel |
| 554 |
p_dlModel: root.p_DNObject !== undefined? root.p_DNObject : [] |
| 555 |
p_dmModel: root.p_DMObject !== undefined? root.p_DMObject : [] |
| 556 |
p_adressModel: root.p_adressModel |
| 557 |
p_additionalModel: root.p_additionalModel |
| 558 |
Keys.priority: Keys.BeforeItem |
| 559 |
Keys.forwardTo: [root] |
| 560 |
onP_modeChanged: { |
| 561 |
root.p_addPhoto = (p_mode === "add_photo") |
| 562 |
onIClickedAction: { |
| 563 |
root.p_centerSide.p_overflow.visible = true |
| 564 |
filterArea.p_showAction = false |
| 565 |
var _name = '' |
| 566 |
if (name.length) { |
| 567 |
_name = RSData.aEscape(name) |
| 568 |
switch (action) { |
| 569 |
case "call": |
| 570 |
if (kvs.featureSet.aVisibleCalls()) { |
| 571 |
if (!kvs.featureSet.p_showRingOutIfVoIPEnabled) { |
| 572 |
xroot.startCall(number, false, root.p_centerSide.getCallsCallerID()); |
| 573 |
else { |
| 574 |
if (kvs.featureSet.getProperty("RingOutFeature") === true) { |
| 575 |
root.p_centerSide.p_ringoutContact.p_value = number |
| 576 |
root.p_centerSide.p_ringOutStatus.p_number = number |
| 577 |
root.p_centerSide.setDisplay('workarea.ringout_call') |
| 578 |
else if (kvs.featureSet.getProperty("RingOutFeature") === true) { |
| 579 |
root.p_centerSide.p_ringoutContact.p_value = number |
| 580 |
root.p_centerSide.p_ringOutStatus.p_number = number |
| 581 |
root.p_centerSide.setDisplay('workarea.ringout_call') |
| 582 |
break; |
| 583 |
case "fax": |
| 584 |
root.p_centerSide.setDisplay('faxout.faxout') |
| 585 |
root.p_centerSide.p_faxoutContact = "{\"name\": \"" + _name + "\" , \"phoneNumber\": \""+ number +"\" " |
| 586 |
break; |
| 587 |
case "text": |
| 588 |
root.p_centerSide.setDisplay('messenger.messenger') |
| 589 |
root.p_centerSide.p_messengerContact = "{\"name\": \"" + _name + "\" , \"phoneNumber\": \""+ number +"\" " |
| 590 |
break; |
| 591 |
onIShowDetailsAction: { |
| 592 |
contactDetailsInner.parent.iShowDetailsAction(show, "clickBack") |
| 593 |
if (show) { |
| 594 |
root.aShowAddPhotoBox("edit", true) |
| 595 |
contactDetailsInner.p_visible = true |
| 596 |
else { |
| 597 |
root.p_backClicked = true |
| 598 |
root.p_dsObject = undefined |
| 599 |
root.aShowAddPhotoBox("show_contact", true) |
| 600 |
contactDetailsInner.p_visible = false |
| 601 |
contactDetailsInner.p_contactID = "0" |
| 602 |
onIMailtoAction: { |
| 603 |
if (contactDetailsInner.p_handlerUrl === undefined) { |
| 604 |
contactDetailsInner.p_handlerUrl = xroot.mailto(value, "", "") |
| 605 |
restartTimerFocus.restart() |
| 606 |
onIEditModeAction: { |
| 607 |
contactDetailsInner.parent.iEditModeAction("edit", "contactDetailsInnerEdit") |
| 608 |
onISaveImageContact: { |
| 609 |
xroot.log("ISaveImageContact " + method, 4) |
| 610 |
var jsonData = "" |
| 611 |
if (contactDetailsInner.p_listType === "personal") { |
| 612 |
jsonData = RightSideJS.aSaveData(root, RSData.p_phoneMap) |
| 613 |
else { |
| 614 |
jsonData = { |
| 615 |
if (contactDetailsInner.p_listType === "personal") { |
| 616 |
jsonData["sourceType"] = contactDetailsInner.p_hiddenProperties.p_sourceType |
| 617 |
var sourceId = parseInt(contactDetailsInner.p_hiddenProperties.p_sourceId) |
| 618 |
jsonData["sourceId"] = sourceId === null ? 0 : sourceId |
| 619 |
jsonData["photoLink"] = contactDetailsInner.p_hiddenProperties.p_photoLink |
| 620 |
if (contactDetailsInner.p_hiddenProperties.p_contactID !== "-1") { |
| 621 |
jsonData["id"] = parseInt(contactDetailsInner.p_hiddenProperties.p_contactID) |
| 622 |
jsonData["remoteId"] = contactDetailsInner.p_hiddenProperties.p_remoteId |
| 623 |
xroot.log("UPDATE CONTACT jsonData: image "+JSON.stringify(jsonData), 4) |
| 624 |
root.p_addToExisting = false; |
| 625 |
root.p_handlerChangeImage = "save_photo" |
| 626 |
if (contactDetailsInner.p_listType === "personal") { |
| 627 |
root.p_handlerUpdate = xroot.updateContact(JSON.stringify(jsonData)); |
| 628 |
else { |
| 629 |
root.p_handlerUpdate = xroot.updateCompanyContact(JSON.stringify(jsonData)); |
| 630 |
onIDuplicateContact: { |
| 631 |
var jsonData = RightSideJS.aSaveData(root, RSData.p_phoneMap); |
| 632 |
jsonData["sourceType"] = "Personal"; jsonData["sourceId"] = 0; |
| 633 |
jsonData["photoLink"] = contactDetailsInner.p_hiddenProperties.p_photoLink; |
| 634 |
xroot.log("Duplicate contact: " + JSON.stringify(jsonData), 4) |
| 635 |
root.p_handlerDuplicate = xroot.addContact(JSON.stringify(jsonData)); |
| 636 |
onIFavoriteAction: { |
| 637 |
if (Qt.isQtObject(root.p_dsObject) && root.p_dsObject.hasAction('toggleItem')) { |
| 638 |
if (SetProperty.aCheckPhone(root.p_dsObject, "phonesCount") || (root.p_dsObject.hasField('hasFavorite') && root.p_dsObject.field('hasFavorite') === '1')) { |
| 639 |
root.p_handlerToggleItem = root.p_dsObject.action('toggleItem'); |
| 640 |
else { |
| 641 |
try { |
| 642 |
xroot.dialogIntf.postShowDialog(JSUtils.cantSelectContactDialog(xroot)); |
| 643 |
catch (e) { |
| 644 |
xroot.log("ERROR Messages onIFavoriteAction: " + e, 1); |
| 645 |
onP_currentSelectedChanged: { |
| 646 |
if (p_currentSelected === -1) { |
| 647 |
restartTimerFocus.restart() |
| 648 |
Component.onCompleted: { |
| 649 |
if (root.p_dsObject) { |
| 650 |
contactDetailsInner.p_hiddenProperties.aClear(); |
| 651 |
contactDetailsInner.p_hiddenProperties.aFillIn(root.p_dsObject) |
| 652 |
Component { |
| 653 |
id: componentEditContact |
| 654 |
ContactEdit { |
| 655 |
id: contactEditInner |
| 656 |
objectName: "contactEdit" |
| 657 |
anchors.fill: parent |
| 658 |
p_hideShow: contactEditInner.parent != null? contactEditInner.parent.p_hideShow : true |
| 659 |
p_imagePath: contactEditInner.parent != null? contactEditInner.parent.p_imagePath : "" |
| 660 |
p_tooltip: root.p_tooltip |
| 661 |
p_isRetina: root.p_isRetina |
| 662 |
p_launcher: root.p_launcher |
| 663 |
p_emailTypes: ListModel { |
| 664 |
p_phoneTypes: ListModel { |
| 665 |
p_infoModel: ListModel { |
| 666 |
p_emailModel: root.p_emailModel |
| 667 |
p_phoneModel: root.p_phoneModel |
| 668 |
p_adressModel: root.p_adressModel |
| 669 |
p_additionalModel: root.p_additionalModel |
| 670 |
p_isHandler: root.p_handlerUpdate !== undefined |
| 671 |
onP_changedChanged: { |
| 672 |
root.p_changed = RightSideJS.aChanged(root, contactEditInner) |
| 673 |
onIEditModeAction: { |
| 674 |
p_mode = mode |
| 675 |
switch (mode) { |
| 676 |
default: |
| 677 |
contactEditInner.forceActiveFocus(); |
| 678 |
root.p_updateContact = true |
| 679 |
contactEditInner.p_editMode = true; |
| 680 |
contactEditInner.p_hiddenProperties.aClear(); |
| 681 |
contactEditInner.p_hiddenProperties.aFillIn(root.p_dsObject) |
| 682 |
contactEditInner.init(); |
| 683 |
break; |
| 684 |
case "add_photo": |
| 685 |
contactEditInner.forceActiveFocus(); |
| 686 |
root.p_updateContact = true |
| 687 |
contactEditInner.p_editMode = true; |
| 688 |
contactEditInner.p_hiddenProperties.aClear(); |
| 689 |
contactEditInner.p_hiddenProperties.aFillIn(root.p_dsObject) |
| 690 |
contactEditInner.init(); |
| 691 |
contactEditInner.aShowAddPhotoBox("add_photo", false) |
| 692 |
break; |
| 693 |
case "cancel": |
| 694 |
if (RightSideJS.aChanged(root, contactEditInner)) { |
| 695 |
root.iShowDialog("edit_contact", "", "") |
| 696 |
else { |
| 697 |
contactEditInner.aCancelAction() |
| 698 |
root.p_updateContact = false |
| 699 |
break; |
| 700 |
case "delete": |
| 701 |
if (root.p_contactID !== -1) { |
| 702 |
xroot.dialogIntf.postShowDialog(RSData.deleteContactDialog); |
| 703 |
root.p_updateContact = false |
| 704 |
break; |
| 705 |
case "save": |
| 706 |
var jsonData = RightSideJS.aSaveData(root, RSData.p_phoneMap) |
| 707 |
jsonData["sourceType"] = contactEditInner.p_hiddenProperties.p_sourceType |
| 708 |
var sourceId = parseInt(contactEditInner.p_hiddenProperties.p_sourceId) |
| 709 |
jsonData["sourceId"] = sourceId === null ? 0 : sourceId |
| 710 |
jsonData["photoLink"] = contactEditInner.p_hiddenProperties.p_photoLink |
| 711 |
if (contactEditInner.p_hiddenProperties.p_photoLink !== contactEditInner.p_imagePath) { |
| 712 |
root.p_handlerChangeImage = "save_photo" |
| 713 |
if (contactEditInner.p_hiddenProperties.p_contactID !== -1) { |
| 714 |
jsonData["id"] = contactEditInner.p_hiddenProperties.p_contactID |
| 715 |
jsonData["remoteId"] = contactEditInner.p_hiddenProperties.p_remoteId |
| 716 |
xroot.log("UPDATE CONTACT jsonData: "+JSON.stringify(jsonData), 4) |
| 717 |
root.p_addToExisting = false; |
| 718 |
root.p_handlerUpdate = xroot.updateContact(JSON.stringify(jsonData)); |
| 719 |
root.p_updateContact = false |
| 720 |
break; |
| 721 |
onIClickedAction: { |
| 722 |
filterArea.p_showAction = false |
| 723 |
function aCancelAction() { |
| 724 |
p_editMode = false; |
| 725 |
contactEditInner.aGetDefault(); |
| 726 |
RightSideJS.aClearModel(root); |
| 727 |
root.init(); |
| 728 |
contactEditInner.parent.iEditModeAction("cancel", "aCancelAction") |
| 729 |
function init() { |
| 730 |
var i = 0; |
| 731 |
contactEditInner.p_hiddenProperties.aClear(); |
| 732 |
contactEditInner.p_hiddenProperties.aFillIn(root.p_dsObject) |
| 733 |
var newInfoModel = RightSideJS.aFillModelNew(RSData.infoModel) |
| 734 |
for (i = 0; i < root.p_infoModel.count; i++) { |
| 735 |
newInfoModel.set(root.p_infoModel.get(i).p_index, {title: root.p_infoModel.get(i).title, active: false, value: root.p_infoModel.get(i).value, jsonField: root.p_infoModel.get(i).jsonField); |
| 736 |
contactEditInner.p_infoModel = newInfoModel; |
| 737 |
var keyValue = { |
| 738 |
var item; |
| 739 |
for (i = contactEditInner.p_infoModel.count-1; i >= 0 ; i--) { |
| 740 |
item = contactEditInner.p_infoModel.get(i).jsonField |
| 741 |
if ((item === "email" || item === "email2" || item === "email3") && contactEditInner.p_infoModel.get(i).value === "") { |
| 742 |
contactEditInner.p_infoModel.remove(i); |
| 743 |
else { |
| 744 |
keyValue[contactEditInner.p_infoModel.get(i).jsonField] = 1 |
| 745 |
if (contactEditInner.p_phoneModel.count > 0) { |
| 746 |
for (i = 0; i < contactEditInner.p_phoneModel.count; i++) { |
| 747 |
keyValue[contactEditInner.p_phoneModel.get(i).jsonField] = i + 1 |
| 748 |
RightSideJS.aPhoneSet(RSData.phoneTypes, p_phoneTypes, function(j, item) {return !keyValue[item.attributes[j].jsonField], function(i, j, item){contactEditInner.p_phoneModel.set((keyValue[item.attributes[j].jsonField] - 1), {'popupIndex': i)) |
| 749 |
xroot.log("Contacts - contactEditInner root.p_phoneNumber: "+root.p_phoneNumber, 4); |
| 750 |
aAddNumber(contactEditInner.p_phoneModel, root.p_phoneNumber); |
| 751 |
RightSideJS.aEmailSet(RSData.emailModel, p_emailTypes, function(key) {return !keyValue[key]) |
| 752 |
ContactsUtils.aInitDefault(contactEditInner) |
| 753 |
Component { |
| 754 |
id: componentAddContact |
| 755 |
ContactEdit { |
| 756 |
id: contactAdd |
| 757 |
objectName: "contactAdd" |
| 758 |
anchors.fill: parent |
| 759 |
p_hideShow: contactAdd.parent != null? contactAdd.parent.p_hideShow : true |
| 760 |
p_tooltip: root.p_tooltip |
| 761 |
p_isRetina: root.p_isRetina |
| 762 |
p_launcher: root.p_launcher |
| 763 |
p_phoneTypes: ListModel { |
| 764 |
p_emailTypes: ListModel { |
| 765 |
p_isUpdate: false |
| 766 |
p_isHandler: root.p_handlerCreate !== undefined |
| 767 |
p_headerTitle: qsTr("Add Contact") + xroot.emptyString |
| 768 |
function init() { |
| 769 |
var i = 0, |
| 770 |
newIndoModel = RightSideJS.aFillModelNew(RSData.infoModel, ["email", "email2", "email3"]); |
| 771 |
contactAdd.p_infoModel = newIndoModel; |
| 772 |
var keyValue = { |
| 773 |
RightSideJS.aPhoneSet(RSData.phoneTypes, p_phoneTypes, function(j,item) {return !keyValue[item.attributes[j].jsonField], function(){) |
| 774 |
xroot.log("Contacts - contactAdd root.p_phoneNumber: "+root.p_phoneNumber, 4) |
| 775 |
aAddNumber(RightSideJS.createListModel(), root.p_phoneNumber); |
| 776 |
RightSideJS.aEmailSet(RSData.emailModel, p_emailTypes, function(key) {return true;) |
| 777 |
var brandId = kvs.userInfo.p_object.hasField("brandCountryId")? kvs.userInfo.p_object.field("brandCountryId") : ""; |
| 778 |
contactAdd.p_adressModel = RightSideJS.aFillModelNew(RSData.getAdressModel(brandId)) |
| 779 |
contactAdd.p_additionalModel = RightSideJS.aFillModelNew(RSData.additionalModel) |
| 780 |
ContactsUtils.aInitDefault(contactAdd) |
| 781 |
onVisibleChanged: { |
| 782 |
if (visible) { |
| 783 |
contactAdd.forceActiveFocus(); |
| 784 |
if (contactAdd.p_hiddenProperties.p_photoLink !== "") { |
| 785 |
p_imageObj = { |
| 786 |
"path": contactAdd.p_hiddenProperties.p_photoLink |
| 787 |
else { |
| 788 |
root.p_imageObj = undefined |
| 789 |
contactAdd.p_hiddenProperties.p_photoLink = "" |
| 790 |
onIEditModeAction: { |
| 791 |
p_mode = mode |
| 792 |
switch (mode) { |
| 793 |
default: |
| 794 |
contactAdd.forceActiveFocus(); |
| 795 |
root.p_updateContact = false |
| 796 |
p_editMode = true; |
| 797 |
contactAdd.aSetDefault() |
| 798 |
contactAdd.init(); |
| 799 |
break; |
| 800 |
case "cancel": |
| 801 |
if (root.p_addContact && RightSideJS.aNotEmpty(root)) { |
| 802 |
root.iShowDialog("add_contact", "", "") |
| 803 |
else { |
| 804 |
contactAdd.aCancelAction() |
| 805 |
break; |
| 806 |
case "save": |
| 807 |
var jsonData = RightSideJS.aSaveData(root, RSData.p_phoneMap) |
| 808 |
jsonData["sourceType"] = contactAdd.p_hiddenProperties.p_sourceType |
| 809 |
var sourceId = parseInt(contactAdd.p_hiddenProperties.p_sourceId) |
| 810 |
jsonData["sourceId"] = sourceId === null ? 0 : sourceId |
| 811 |
jsonData["photoLink"] = contactAdd.p_hiddenProperties.p_photoLink |
| 812 |
xroot.log("JSON p_handlerCreate " + JSON.stringify(jsonData), 4) |
| 813 |
root.p_handlerCreate = xroot.addContact(JSON.stringify(jsonData)); |
| 814 |
p_editMode = false |
| 815 |
root.p_imageObj = undefined |
| 816 |
root.p_phoneNumber = "" |
| 817 |
contactAdd.p_hiddenProperties.aClear(); |
| 818 |
break; |
| 819 |
onIClickedAction: { |
| 820 |
filterArea.p_showAction = false |
| 821 |
function aCancelAction() { |
| 822 |
p_editMode = false; |
| 823 |
contactAdd.aGetDefault(); |
| 824 |
RightSideJS.aClearModel(root) |
| 825 |
contactAdd.parent.iShowDetailsAction(false, "createContact_cancel") |
| 826 |
Row { |
| 827 |
id: content1 |
| 828 |
width: root.width |
| 829 |
height: root.height |
| 830 |
Behavior on x { |
| 831 |
NumberAnimation { duration: root.p_isAnimation? 300 : 0 Rectangle { |
| 832 |
id: contactsList |
| 833 |
width: root.width |
| 834 |
height: root.height |
| 835 |
color: kvs.uiScheme.getStyleProperty("color1", 'transparent') |
| 836 |
Component { |
| 837 |
id: sectionItem |
| 838 |
SectionHeader { |
| 839 |
id: section |
| 840 |
objectName: "section" |
| 841 |
property variant dsObject: parent != null? parent.dsObject : undefined |
| 842 |
property bool isCompleted: dsObject !== null && dsObject !== undefined && dsObject.field('ready') |
| 843 |
p_text: isCompleted && dsObject.hasField('section')? dsObject.field('section') : "" |
| 844 |
p_isRetina: root.p_isRetina |
| 845 |
width: leftSidePersonal.width |
| 846 |
height: 22 |
| 847 |
Rectangle { |
| 848 |
id: separator |
| 849 |
height: 1 |
| 850 |
width: parent.width |
| 851 |
color: kvs.uiScheme.getStyleProperty("color1", 'transparent') |
| 852 |
anchors { |
| 853 |
top: parent.top |
| 854 |
topMargin: -1 |
| 855 |
Item { |
| 856 |
anchors.fill: parent |
| 857 |
opacity: !parent.isCompleted? 1 : 0 |
| 858 |
visible: (opacity > 0) |
| 859 |
z: parent.z + 1 |
| 860 |
Behavior on opacity { |
| 861 |
NumberAnimation { duration: 300 MouseArea { |
| 862 |
anchors.fill: parent |
| 863 |
preventStealing: false |
| 864 |
Rectangle { |
| 865 |
anchors.fill: parent |
| 866 |
color: "transparent" |
| 867 |
visible: parent.visible |
| 868 |
opacity: parent.opacity |
| 869 |
Behavior on opacity { |
| 870 |
NumberAnimation { duration: 300 Rectangle { |
| 871 |
height: 1 |
| 872 |
width: parent.width |
| 873 |
color: section.p_topLineColor |
| 874 |
onIClickedAction: { |
| 875 |
filterArea.p_showAction = false |
| 876 |
Component { |
| 877 |
id: selectContactFooter |
| 878 |
Item { |
| 879 |
visible: ListView.view !== null && ListView.view.p_moreLoad? true : false |
| 880 |
width: parent !== null? parent.width : 0 |
| 881 |
height: visible? 40 : 0 |
| 882 |
z: parent.z + 1 |
| 883 |
Rectangle { |
| 884 |
width: parent.width |
| 885 |
height: parent.height |
| 886 |
color: kvs.uiScheme.getStyleProperty("color25", 'transparent') |
| 887 |
anchors.bottom: parent.bottom |
| 888 |
visible: parent.visible |
| 889 |
Text { |
| 890 |
objectName: "text" |
| 891 |
antialiasing: true |
| 892 |
renderType: root.p_isRetina ? Text.QtRendering : Text.NativeRendering |
| 893 |
text: qsTr("Loading...") + xroot.emptyString |
| 894 |
anchors.centerIn: parent |
| 895 |
color: kvs.uiScheme.getStyleProperty("color19", 'transparent') |
| 896 |
font { |
| 897 |
family: kvs.uiScheme.getFont('normal') |
| 898 |
pixelSize: 14 |
| 899 |
Connections { |
| 900 |
target: xroot.dialogIntf |
| 901 |
ignoreUnknownSignals: true |
| 902 |
onUiRequestedDialogClosed: { |
| 903 |
if (bName === "Ok") { |
| 904 |
switch(id) { |
| 905 |
case "cancel_item_add_contact": |
| 906 |
case "cancel_item_edit_contact": { |
| 907 |
contactDetailsPersonal.item.aCancelAction(); |
| 908 |
menuitem.aGetRecordByID('cancel_item', root.p_selectID) |
| 909 |
dataContactsList.p_view.currentIndex = root.p_selectIndex |
| 910 |
root.p_selectID = '' |
| 911 |
break; |
| 912 |
Component { |
| 913 |
id: lineItem |
| 914 |
ContactItem { |
| 915 |
id: menuitem |
| 916 |
property variant dsObject: parent != null? parent.dsObject : undefined |
| 917 |
property bool isCompleted: dsObject !== null && dsObject !== undefined && dsObject.field('ready') |
| 918 |
property string p_status: "" |
| 919 |
property string _state: "" |
| 920 |
property int p_textLength: parent!==null && parent.p_hideLine ? p_text.length : 1 |
| 921 |
property string p_lastModifiedTime: isCompleted && dsObject.hasField('lastModifiedTime')? dsObject.field('lastModifiedTime') : "" |
| 922 |
width: parent != null? parent.ListView.view.width : 0 |
| 923 |
visible: ((parent != null && parent.p_index > 0) || p_internal.p_text.length || searchPanelContacts.p_value.length)? true : false |
| 924 |
p_index: parent != null? parent.p_index : 0 |
| 925 |
p_isRetina: root.p_isRetina |
| 926 |
p_ID: isCompleted? (dsObject.hasField('id')? dsObject.field('id') : '0') : 'not-ready' |
| 927 |
p_subscribeId: dataContactsList.p_subscribeId |
| 928 |
p_emailModel: root.p_emailModel |
| 929 |
p_phoneModel: root.p_phoneModel |
| 930 |
p_dlModel:root.p_dlModel |
| 931 |
p_tooltip: root.p_tooltip |
| 932 |
p_isFavorite: { |
| 933 |
if (isCompleted) { |
| 934 |
if (dsObject.hasField('hasFavorite') && dsObject.field('hasFavorite') === '1') { |
| 935 |
return true; |
| 936 |
return false; |
| 937 |
return undefined; |
| 938 |
p_extStatus: { |
| 939 |
if (isCompleted) { |
| 940 |
var _status = "" |
| 941 |
if (dsObject.hasField('message')&&dsObject.field('message')!=="") { |
| 942 |
_status = dsObject.field('message') |
| 943 |
else { |
| 944 |
if (dsObject.hasField("presenceStatus") && dsObject.field("presenceStatus")) { |
| 945 |
_status = dsObject.field("presenceStatus") |
| 946 |
return "" |
| 947 |
else return "not-ready" |
| 948 |
p_telephonyStatus: { |
| 949 |
if (isCompleted) { |
| 950 |
if (parent.listType !== 'personal') { |
| 951 |
return JSUtils.getStatus(dsObject); |
| 952 |
else { |
| 953 |
return "" |
| 954 |
return "not-ready" |
| 955 |
Connections { |
| 956 |
target: xroot |
| 957 |
ignoreUnknownSignals: true |
| 958 |
onOwnPhotoChanged: { |
| 959 |
if (menuitem.isCompleted && !root.p_addPhoto) { |
| 960 |
menuitem.aIndexCheckGetRecord("p_imagePath "); |
| 961 |
Connections { |
| 962 |
target: filterArea |
| 963 |
onISetType: { |
| 964 |
if(0 !== type) { |
| 965 |
root.aClearSubscribe(); |
| 966 |
onIContactInfoAction: { |
| 967 |
filterArea.p_showAction = false |
| 968 |
if (!((menuitem.p_isOsxContact || menuitem.p_isOutlook || menuitem.p_listType === "company") && root.p_addToExisting)) { |
| 969 |
if (!(contactDetailsPersonal.p_editMode || root.p_addPhoto) && (menuitem.p_ID !== dataContactsList.p_subscribeId)) { |
| 970 |
menuitem.aGetRecordByID("0 onIContactInfoAction " + p_index) |
| 971 |
else { |
| 972 |
if (dataContactsList.p_subscribeId !== "" && menuitem.p_ID !== dataContactsList.p_subscribeId) { |
| 973 |
if (root.p_addContact) { |
| 974 |
if (RightSideJS.aNotEmpty(root)) { |
| 975 |
root.p_selectID = menuitem.p_internal.p_ID |
| 976 |
root.p_selectIndex = menuitem.p_index |
| 977 |
root.iShowDialog('item_add_contact', 'Warning' + xroot.emptyString , 'You have made the changes that will be lost if you terminate the edit process. Do you want to discard them?' + xroot.emptyString) |
| 978 |
else { |
| 979 |
menuitem.aGetRecordByID("1 onIContactInfoAction " + p_index) |
| 980 |
else { |
| 981 |
if (RightSideJS.aChanged(root, contactDetailsPersonal.item)) { |
| 982 |
root.p_selectID = menuitem.p_internal.p_ID |
| 983 |
root.p_selectIndex = menuitem.p_index |
| 984 |
root.iShowDialog('item_edit_contact', 'Warning' + xroot.emptyString , 'You have made the changes that will be lost if you terminate the edit process. Do you want to discard them?' + xroot.emptyString) |
| 985 |
else { |
| 986 |
menuitem.aGetRecordByID("2 onIContactInfoAction " + p_index) |
| 987 |
else { |
| 988 |
try { |
| 989 |
xroot.dialogIntf.postShowDialog( |
| 990 |
JSON.stringify( |
| 991 |
{ |
| 992 |
"id": 'msg_dialog', |
| 993 |
"title": qsTr('Cannot append the number') + xroot.emptyString, |
| 994 |
"msg": qsTr('This contact has been imported from an external application and cannot be modified.') + xroot.emptyString, |
| 995 |
"buttonList" : [ |
| 996 |
{ |
| 997 |
"buttonName" : "Cancel", |
| 998 |
"buttonText" : qsTr("Close") + xroot.emptyString, |
| 999 |
"buttonStyle" : "buttonStyleTwo" |
| 1000 |
] |
| 1001 |
) |
| 1002 |
); |
| 1003 |
catch (e) { |
| 1004 |
xroot.log("ERROR Contacts onIContactInfoAction: " + e, 1); |
| 1005 |
onIClickedAction: { |
| 1006 |
onIFavoriteAction: { |
| 1007 |
filterArea.p_showAction = false |
| 1008 |
if (menuitem.dsObject.hasAction('toggleItem')) { |
| 1009 |
if (SetProperty.aCheckPhone(menuitem.dsObject, "phonesCount") || (dsObject.hasField('hasFavorite') && dsObject.field('hasFavorite') === '1')) { |
| 1010 |
root.p_handlerToggleItem = menuitem.dsObject.action('toggleItem'); |
| 1011 |
else { |
| 1012 |
try { |
| 1013 |
xroot.dialogIntf.postShowDialog(JSUtils.cantSelectContactDialog(xroot)); |
| 1014 |
catch (e) { |
| 1015 |
xroot.log("ERROR Contacts onIFavoriteAction: " + e, 1); |
| 1016 |
onIsCompletedChanged: { |
| 1017 |
if (isCompleted) { |
| 1018 |
p_text = JSUtils.getName(dsObject); |
| 1019 |
p_isOutlook = dsObject.hasField('sourceTypeId') && dsObject.field('sourceTypeId') === "8"? true : false; |
| 1020 |
p_isOsxContact = dsObject.hasField('sourceTypeId') && dsObject.field('sourceTypeId') === "4"? true : false; |
| 1021 |
if (dsObject.hasField('sourceTypeId') && dsObject.field('sourceTypeId') === "2") { |
| 1022 |
parent.listType = "company"; |
| 1023 |
p_listType = "company"; |
| 1024 |
else { |
| 1025 |
parent.listType = "personal"; |
| 1026 |
p_listType = "personal"; |
| 1027 |
p_extension = "" |
| 1028 |
if (parent.listType !== 'personal') { |
| 1029 |
if (SetProperty.aCheckPhone(dsObject, "phonesCount")) { |
| 1030 |
try { |
| 1031 |
if (dsObject.hasField('phones')) { |
| 1032 |
var _phones = JSON.parse(dsObject.field('phones')) |
| 1033 |
p_extension = _phones["phones"][0].number |
| 1034 |
catch (e) { |
| 1035 |
xroot.log("ERROR: Contacts parse phones - " + e, 1) |
| 1036 |
p_imagePath = (dsObject.hasField('photoLink') && dsObject.field('photoLink').length && root.p_handlerChangeImage === undefined)? dsObject.field('photoLink') + "?" + Math.random() : "" |
| 1037 |
if (root.p_getRecordByID !== "" /*&& root.p_currentIndex !== -1*/) { |
| 1038 |
menuitem.aIndexCheckGetRecord("isCompleted "); |
| 1039 |
root.p_getRecordByID = "" |
| 1040 |
onP_lastModifiedTimeChanged: { |
| 1041 |
if (p_lastModifiedTime.length) { |
| 1042 |
p_imagePath = ""; |
| 1043 |
p_imagePath = isCompleted? (dsObject.hasField('photoLink') && dsObject.field('photoLink').length && root.p_handlerChangeImage === undefined)? dsObject.field('photoLink') : "" : "not-ready"; |
| 1044 |
Component.onCompleted: { |
| 1045 |
if (dataContactsList.p_subscribeId === menuitem.p_internal.p_ID){ |
| 1046 |
menuitem.aIndexCheckGetRecord("onP_indexChanged ") |
| 1047 |
onP_indexChanged: { |
| 1048 |
if (p_ID !== "not-ready" && menuitem.p_internal.p_ID === p_ID && dataContactsList.p_subscribeId === menuitem.p_internal.p_ID){ |
| 1049 |
menuitem.aIndexCheckGetRecord("onP_indexChanged: ["+p_ID+"] ") |
| 1050 |
onP_IDChanged: { |
| 1051 |
if(p_ID !== "not-ready") { |
| 1052 |
if (menuitem.p_internal.p_ID !== p_ID && dataContactsList.p_subscribeId === menuitem.p_internal.p_ID){ |
| 1053 |
menuitem.aIndexCheckGetRecord("onP_IDChanged: ["+p_ID+"] ") |
| 1054 |
iGoToIndex(); |
| 1055 |
if(p_index === root.p_gotoIndex) { |
| 1056 |
dataContactsList.p_subscribeId = p_ID; |
| 1057 |
root.p_gotoIndex = -1; |
| 1058 |
iGoToIndex(); |
| 1059 |
menuitem.aIndexCheckGetRecord("onP_IDChanged: ["+p_ID+"] ") |
| 1060 |
onIGoToIndex: { |
| 1061 |
dataContactsList.p_view.positionViewAtIndex(p_index, ListView.Contain ); |
| 1062 |
function aIndexCheckGetRecord(name) { |
| 1063 |
if (dataContactsList.p_subscribeId !== "" && menuitem.p_internal.p_ID !== "0") { |
| 1064 |
menuitem.aGetRecordByID(name + p_index + " " + (root.p_currentIndex - 1)); |
| 1065 |
function aGetRecordByID(method) { |
| 1066 |
xroot.log("aGetRecordByID " + method + ' dataContactsList.p_subscribeId ' + dataContactsList.p_subscribeId + " == "+menuitem.p_internal.p_ID+" menuitem.p_internal.p_ID ", 4) |
| 1067 |
if (root.visible) { |
| 1068 |
filterArea.p_showAction = false |
| 1069 |
var _id = (menuitem.isCompleted && menuitem.dsObject.hasField('id')? menuitem.dsObject.field('id') : '0') |
| 1070 |
if (menuitem.isCompleted && _id !== '0') { |
| 1071 |
root.p_isLoading = true; |
| 1072 |
if (dataContactsList.p_subscribeId.length && dataContactsList.p_masterRecord.hasAction('unsubscribeFromRecordTracking')) { |
| 1073 |
dataContactsList.p_masterRecord.action('unsubscribeFromRecordTracking', dataContactsList.p_subscribeId) |
| 1074 |
xroot.log("aGetRecordContact " + _id + ' dataContactsList.p_subscribeId ' + dataContactsList.p_subscribeId, 4) |
| 1075 |
root.p_contactDB = xroot.getDB(dataContactsList.p_db); |
| 1076 |
root.p_backClicked = false |
| 1077 |
if(dataContactsList.p_subscribeId !== _id) { |
| 1078 |
dataContactsList.p_subscribeId = _id; |
| 1079 |
dataContactsList.p_masterRecord.action('subscribeToRecordTracking', dataContactsList.p_subscribeId) |
| 1080 |
root.p_contactDB.requestRecordById(_id) |
| 1081 |
else { |
| 1082 |
root.p_getRecordByID = "aGetRecordByID" |
| 1083 |
MouseArea { |
| 1084 |
anchors.fill: parent |
| 1085 |
acceptedButtons: Qt.RightButton |
| 1086 |
onClicked: { |
| 1087 |
if (menuitem.parent.listType === 'personal') { |
| 1088 |
root.p_selectID = menuitem.p_internal.p_ID; |
| 1089 |
editMenu.p_isExternal = menuitem.p_isOutlook || menuitem.p_isOsxContact |
| 1090 |
xroot.log('Show Context Menu', 4); |
| 1091 |
editMenu.menuPopup(); |
| 1092 |
Component { |
| 1093 |
id: emptyItem |
| 1094 |
Item { |
| 1095 |
height: 0 |
| 1096 |
width: 0 |
| 1097 |
visible: false |
| 1098 |
SearchPanel { |
| 1099 |
id: searchPanelContacts |
| 1100 |
objectName: "searchPanelContacts" |
| 1101 |
width: parent.width |
| 1102 |
height: 40 |
| 1103 |
anchors { |
| 1104 |
top: parent.top |
| 1105 |
clip: true |
| 1106 |
p_isRetina: root.p_isRetina |
| 1107 |
p_placeHolderText: "" |
| 1108 |
p_spacing: 10 |
| 1109 |
z: contactsTabs.z + 1 |
| 1110 |
p_readOnly: !root.p_visible |
| 1111 |
&& (root.p_addContact |
| 1112 |
|| root.p_addToExisting |
| 1113 |
|| contactDetailsPersonal.p_editMode |
| 1114 |
|| contactsTabs.p_rightOpened) |
| 1115 |
p_emptySearch: { |
| 1116 |
var list = dataContactsList; |
| 1117 |
try { |
| 1118 |
if (searchPanelContacts.p_value.trim().length && list.visible && list.p_view.count === 0) { |
| 1119 |
return true; |
| 1120 |
catch(e) { |
| 1121 |
xroot.log("ERROR Messages p_emptySearch: " + e, 1) |
| 1122 |
return false; |
| 1123 |
p_loaderRight: Component { |
| 1124 |
Item { |
| 1125 |
width: containerAction.width |
| 1126 |
height: containerAction.height |
| 1127 |
Row { |
| 1128 |
id: containerAction |
| 1129 |
spacing: 6 |
| 1130 |
IconButton { |
| 1131 |
id: filterAction |
| 1132 |
objectName: "filterAction" |
| 1133 |
p_tooltip: root.p_tooltip |
| 1134 |
p_tooltipContent: qsTr("Filter") + xroot.emptyString |
| 1135 |
p_size: 20 |
| 1136 |
p_isRetina: root.p_isRetina |
| 1137 |
p_icon: 'statusbar/actions/filter' |
| 1138 |
p_active: (filterArea.p_filterActionMenu.count && filterArea.p_filterActionMenu.get(0)!== undefined && filterArea.p_filterActionMenu.get(0).selected === "0") |
| 1139 |
enabled: !p_dissabled |
| 1140 |
onIClickedAction: { |
| 1141 |
parent.parent.parent.iClickedAction("filter_contact") |
| 1142 |
visible: !contactDetailsPersonal.p_editMode && filterArea.p_filterActionMenu.count > 1 |
| 1143 |
IconButton { |
| 1144 |
id: addAction |
| 1145 |
objectName: "addAction" |
| 1146 |
p_tooltip: root.p_tooltip |
| 1147 |
p_tooltipContent: qsTr("Add Contact") + xroot.emptyString |
| 1148 |
p_size: 19 |
| 1149 |
p_isRetina: root.p_isRetina |
| 1150 |
p_icon: 'statusbar/actions/btn_add_recipient' |
| 1151 |
p_dissabled: kvs.featureSet.getProperty('isOffline') === true || kvs.featureSet.getProperty('isVoIp') === true |
| 1152 |
enabled: !p_dissabled |
| 1153 |
onIClickedAction: { |
| 1154 |
parent.parent.parent.iClickedAction("add_contact") |
| 1155 |
visible: !root.p_addContact && !contactDetailsPersonal.p_editMode && !root.p_addToExisting && kvs.featureSet.getPermission('EditPersonalContacts') |
| 1156 |
onIClickedAction: { |
| 1157 |
switch (action) { |
| 1158 |
case 'mouseArea': |
| 1159 |
filterArea.p_showAction = false |
| 1160 |
break; |
| 1161 |
case 'add_contact': |
| 1162 |
filterArea.p_showAction = false |
| 1163 |
contactDetailsPersonal.iEditModeAction("add_contact", "clickButtonAdd") |
| 1164 |
break; |
| 1165 |
case 'filter_contact': |
| 1166 |
filterArea.p_showAction = !filterArea.p_showAction |
| 1167 |
break; |
| 1168 |
onVisibleChanged: { |
| 1169 |
if (visible) { |
| 1170 |
restartFocus(); |
| 1171 |
onP_readOnlyChanged: { |
| 1172 |
if (!p_readOnly) { |
| 1173 |
restartTimerFocus.restart() |
| 1174 |
onIPressedAction: { |
| 1175 |
var list = dataContactsList; |
| 1176 |
var eventKeys = [Qt.Key_Home, Qt.Key_End, Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown]; |
| 1177 |
if (eventKeys.contains(event.key)) { |
| 1178 |
list.iInKeyPress(event); |
| 1179 |
else { |
| 1180 |
if (event.key === Qt.Key_Backtab) { |
| 1181 |
root.p_centerSide.p_topSide.p_iconBar.forceActiveFocus(); |
| 1182 |
event.accepted = true; |
| 1183 |
if (event.key === Qt.Key_Tab && (!event.modifiers || (event.modifiers | Qt.ControlModifier))) { |
| 1184 |
root.p_launcher.forceActiveFocus(); |
| 1185 |
event.accepted = true; |
| 1186 |
onITrigered: { |
| 1187 |
filterArea.p_showAction = false |
| 1188 |
filterArea.aSetDataFilter(dataContactsList, 'contactType') |
| 1189 |
function restartFocus() { |
| 1190 |
restartTimerFocus.restart() |
| 1191 |
Timer { |
| 1192 |
id: restartTimerFocus |
| 1193 |
interval: 100 |
| 1194 |
onTriggered: { |
| 1195 |
xroot.log('Timer restartTimerFocus in Contacts onTriggered', 4); |
| 1196 |
if (!searchPanelContacts.p_readOnly && root.p_visible && !contactsTabs.p_rightOpened) { |
| 1197 |
searchPanelContacts.setFocus(); |
| 1198 |
if (contactsTabs.p_rightOpened) { |
| 1199 |
rightSidePersonal.forceActiveFocus() |
| 1200 |
rightSidePersonal.focus = true |
| 1201 |
contactDetailsPersonal.forceActiveFocus() |
| 1202 |
contactDetailsPersonal.focus = true |
| 1203 |
FilterArea { |
| 1204 |
id: filterArea |
| 1205 |
p_centerSide: root.p_centerSide |
| 1206 |
p_tooltip: root.p_tooltip |
| 1207 |
p_searchPanel: searchPanelContacts |
| 1208 |
p_isRetina: root.p_isRetina |
| 1209 |
p_area: 'Contact' |
| 1210 |
Rectangle { |
| 1211 |
id: contactsTabs |
| 1212 |
objectName: "contactsTabs" |
| 1213 |
width: parent.width |
| 1214 |
height: parent.height |
| 1215 |
visible: parent.visible |
| 1216 |
property int t_current: 0 |
| 1217 |
property int p_searchHeight: 43 |
| 1218 |
property bool p_rightOpened: contactsTabs.width < 600 && root.p_rightOpened |
| 1219 |
function setDB(DSList) { |
| 1220 |
if (DSList.visible && DSList.p_db.length) { |
| 1221 |
if (DSList.p_target === DSList) { |
| 1222 |
xroot.log('xroot.getDB SelectContact 9 ' + DSList.p_db, 4) |
| 1223 |
DSList.p_target = xroot.getDB(DSList.p_db); |
| 1224 |
DSList.sizeChange(); |
| 1225 |
DSList.t_masterRecord = DSList.p_target.getMasterRecord(); |
| 1226 |
DSList.iMasterRecordChanged(); |
| 1227 |
filterArea.p_isSearch = false |
| 1228 |
if (searchPanelContacts.p_value.length > 0 && !DSList.p_initSearch) { |
| 1229 |
filterArea.aSetDataFilter(dataContactsList, 'contactType') |
| 1230 |
DSList.p_initSearch = true |
| 1231 |
else if (!searchPanelContacts.p_value.length && root.visible) { |
| 1232 |
filterArea.aSetDataFilter(dataContactsList, 'contactType') |
| 1233 |
restartTimerFocus.restart() |
| 1234 |
function aGetDefaultValue(item, list) { |
| 1235 |
root.p_dsObject = undefined |
| 1236 |
root.p_selectID = "" |
| 1237 |
list.p_subscribeId = ""; |
| 1238 |
item.sourceComponent = emptyComponent |
| 1239 |
item.p_editMode = false |
| 1240 |
item.p_contactID = "0" |
| 1241 |
item.p_isFavorite = false |
| 1242 |
item.p_imagePath = "" |
| 1243 |
item.p_text = "" |
| 1244 |
item.p_countPhones = 0 |
| 1245 |
if (root.p_centerSide !== null) { |
| 1246 |
root.p_centerSide.p_overflow.visible = false |
| 1247 |
xroot.log("aGetDefaultValue emptyComponent: " + (item.sourceComponent === emptyComponent) + " " + list.toString() + " " + contactDetailsPersonal.p_contactID, 4) |
| 1248 |
Rectangle { |
| 1249 |
id: contactPersonal |
| 1250 |
objectName: 'contactPersonal' |
| 1251 |
width: parent.width |
| 1252 |
anchors { |
| 1253 |
top: parent.top |
| 1254 |
bottom: parent.bottom |
| 1255 |
topMargin: searchPanelContacts.height - 1 |
| 1256 |
color: "transparent" |
| 1257 |
property string p_title: qsTr("Personal") + xroot.emptyString |
| 1258 |
onVisibleChanged: { |
| 1259 |
if (!visible) { |
| 1260 |
contactDetailsPersonal.iShowDetailsAction(false, "contactPersonal_visible") |
| 1261 |
Rectangle { |
| 1262 |
anchors.fill: parent |
| 1263 |
color: "transparent" |
| 1264 |
visible: parent.visible |
| 1265 |
z: 1 |
| 1266 |
Item { |
| 1267 |
id: sideBySideOuter |
| 1268 |
anchors.fill: parent |
| 1269 |
visible: parent.visible |
| 1270 |
SideBySide { |
| 1271 |
id: sideBySide |
| 1272 |
p_target: parent |
| 1273 |
p_width: parent.width |
| 1274 |
p_leftTarget: leftSidePersonal |
| 1275 |
p_rightOpened: root.p_rightOpened |
| 1276 |
p_search: searchPanelContacts |
| 1277 |
p_visible: visible |
| 1278 |
visible: parent.visible |
| 1279 |
Rectangle { |
| 1280 |
id: leftSidePersonal |
| 1281 |
height: parent.height |
| 1282 |
color: "transparent" |
| 1283 |
clip: true |
| 1284 |
Item { |
| 1285 |
id: addContactElement |
| 1286 |
width: parent.width |
| 1287 |
height: root.p_addContact? childrenRect.height : 0 |
| 1288 |
clip: true |
| 1289 |
Behavior on height { |
| 1290 |
NumberAnimation { duration: contactsTabs.state === "sideBySide_default"? 300 : 0 ContactItem { |
| 1291 |
width: parent.width |
| 1292 |
p_isRetina: root.p_isRetina |
| 1293 |
p_tooltip: root.p_tooltip |
| 1294 |
p_text: qsTr("New Contact") + xroot.emptyString |
| 1295 |
p_bgColor: kvs.uiScheme.getStyleProperty("color19", 'transparent') |
| 1296 |
DSListModel { |
| 1297 |
id: dataContactsList |
| 1298 |
objectName: "dataContactsList" |
| 1299 |
property bool p_showButtons: true |
| 1300 |
property bool p_completeSearch: true |
| 1301 |
property bool p_initSearch: false |
| 1302 |
property string p_subscribeId: '' |
| 1303 |
property string p_contactFilterTypeMenu: '' |
| 1304 |
visible: sideBySide.visible |
| 1305 |
width: parent.width |
| 1306 |
anchors.top: addContactElement.bottom |
| 1307 |
p_delegateItem: Loader { |
| 1308 |
id: personalLoader |
| 1309 |
objectName: "personalLoader" + p_index |
| 1310 |
property variant t_record: record |
| 1311 |
property variant dsObject: initDsObject() |
| 1312 |
property bool isCompleted: (dsObject !== null && dsObject.field('ready')) |
| 1313 |
property string listType: "personal" |
| 1314 |
property int p_index: index |
| 1315 |
property int p_y: ListView.view.contentY |
| 1316 |
property QtObject p_view: ListView.view |
| 1317 |
width: ListView.view.width |
| 1318 |
Component.onCompleted: { |
| 1319 |
if (dsObject !== null) { |
| 1320 |
if (dsObject.hasField('section') && sourceComponent != sectionItem) { |
| 1321 |
sourceComponent = sectionItem; |
| 1322 |
if (!dsObject.hasField('section') && sourceComponent != lineItem && (p_index === 0 && !searchPanelContacts.p_value.length)) { |
| 1323 |
sourceComponent = emptyItem |
| 1324 |
else if (!dsObject.hasField('section') && sourceComponent != lineItem) { |
| 1325 |
sourceComponent = lineItem; |
| 1326 |
onIsCompletedChanged: { |
| 1327 |
if (isCompleted) { |
| 1328 |
if (dsObject.hasField('section') && sourceComponent != sectionItem) { |
| 1329 |
sourceComponent = sectionItem; |
| 1330 |
if (!dsObject.hasField('section') && sourceComponent != lineItem) { |
| 1331 |
sourceComponent = lineItem; |
| 1332 |
function initDsObject() { |
| 1333 |
return t_record !== undefined? xroot.extract(t_record) : null; |
| 1334 |
p_delegateFooter: selectContactFooter |
| 1335 |
p_loaderItem: BusyIndicator { |
| 1336 |
visible: false |
| 1337 |
anchors.centerIn: parent |
| 1338 |
p_loaderSource: JSUtils.getImagePath(xroot, "loaders/loading.svg") |
| 1339 |
p_show: dataContactsList.visible |
| 1340 |
function show() { visible = true function hide() { visible = false p_emptyItem: Item { |
| 1341 |
height: parent.height |
| 1342 |
width: parent.width |
| 1343 |
objectName: "EmptyItemPersonal" |
| 1344 |
property alias p_text: text.text |
| 1345 |
Text { |
| 1346 |
id: text |
| 1347 |
objectName: "text" |
| 1348 |
antialiasing: true |
| 1349 |
renderType: root.p_isRetina ? Text.QtRendering : Text.NativeRendering |
| 1350 |
text: "" |
| 1351 |
anchors.centerIn: parent |
| 1352 |
color: kvs.uiScheme.getStyleProperty("color28", 'transparent') |
| 1353 |
font { |
| 1354 |
family: kvs.uiScheme.getFont('normal') |
| 1355 |
pixelSize: 14 |
| 1356 |
visible: !root.p_addContact |
| 1357 |
MouseArea { |
| 1358 |
anchors.fill: parent |
| 1359 |
visible: parent.opacity > 0 |
| 1360 |
onClicked: { |
| 1361 |
filterArea.p_showAction = false |
| 1362 |
function show() { |
| 1363 |
opacity = 1; |
| 1364 |
text.text = parent.parent.p_text; |
| 1365 |
root.aClearSubscribe(); |
| 1366 |
contactDetailsPersonal.sourceComponent = emptyComponent |
| 1367 |
function hide() { |
| 1368 |
opacity = 0; |
| 1369 |
Behavior on opacity { |
| 1370 |
NumberAnimation { duration: 300 p_viewHeight: parent.height |
| 1371 |
p_viewWidth: parent.width - p_scrollBarWidth |
| 1372 |
p_viewSpacing: 0 |
| 1373 |
p_text: { |
| 1374 |
if (!dataContactsList.p_countFirst) { |
| 1375 |
return qsTr("No contacts to display") + xroot.emptyString |
| 1376 |
else { |
| 1377 |
return ( !dataContactsList.p_count)? qsTr("No Results") + xroot.emptyString : "" p_interactive: !contactDetailsPersonal.p_editMode |
| 1378 |
onP_subscribeIdChanged: { |
| 1379 |
xroot.log("onP_subscribeIdChanged: (dataContactsList) "+p_subscribeId, 4) |
| 1380 |
contactDetailsPersonal.iEditModeAction("cancel", "aCancelAction") |
| 1381 |
if(p_subscribeId == "") { |
| 1382 |
contactsTabs.aGetDefaultValue(contactDetailsPersonal, dataContactsList); |
| 1383 |
onIMoveStartAction: { |
| 1384 |
root.p_tooltip.p_text = "" |
| 1385 |
root.p_tooltip.p_capitalize = Font.MixedCase; |
| 1386 |
onP_masterRecordChanged: { |
| 1387 |
if (p_masterRecord !== undefined && p_masterRecord !== null) { |
| 1388 |
xroot.log("Personal list p_masterRecord " + p_masterRecord.info(), 4) |
| 1389 |
if (p_masterRecord.hasField("contactFilterTypeMenu") && p_contactFilterTypeMenu != p_masterRecord.field("contactFilterTypeMenu")) { |
| 1390 |
filterArea.aSetFilterItem(dataContactsList, true) |
| 1391 |
p_contactFilterTypeMenu = p_masterRecord.field("contactFilterTypeMenu") |
| 1392 |
onP_targetChanged: { |
| 1393 |
if (p_target !== dataContactsList) { |
| 1394 |
dataContactsList.sizeChange(); |
| 1395 |
onP_textChanged: { |
| 1396 |
if (p_emptyLoader.item !== null) { |
| 1397 |
p_emptyLoader.item.p_text = p_text |
| 1398 |
onVisibleChanged: { |
| 1399 |
contactsTabs.setDB(dataContactsList); |
| 1400 |
onP_dbChanged: { |
| 1401 |
contactsTabs.setDB(dataContactsList); |
| 1402 |
onIEmptyContentChanged: { |
| 1403 |
root.aClearSubscribe(); |
| 1404 |
onIMasterRecordChanged: { |
| 1405 |
try { |
| 1406 |
if (dataContactsList.p_masterRecord.field('ready') && !root.p_editMode) { |
| 1407 |
var trackings = JSON.parse(dataContactsList.p_masterRecord.field('trackingRecords')); |
| 1408 |
if (trackings['Changed'] || trackings['Deleted']) { |
| 1409 |
if (trackings['Changed'].contains(dataContactsList.p_subscribeId) || trackings['Deleted'].contains(dataContactsList.p_subscribeId)) { |
| 1410 |
dataContactsList.p_target.requestRecordById(contactDetailsPersonal.p_contactID? contactDetailsPersonal.p_contactID : "0") |
| 1411 |
catch(e) { |
| 1412 |
xroot.log("ERROR Subscribe Contacts MasterRecord: " + e, 1); |
| 1413 |
Rectangle { |
| 1414 |
id: rightSidePersonal |
| 1415 |
height: parent.height |
| 1416 |
color: kvs.uiScheme.getStyleProperty("color2", 'transparent') |
| 1417 |
width: rightSidePersonal.p_showSeparator? sideBySide.p_width : Math.max(300, sideBySide.width - leftSidePersonal.width + Math.abs(sideBySide.x) - sideBySide.p_width) |
| 1418 |
property bool p_showSeparator: sideBySide.p_width < 600 |
| 1419 |
Loader { |
| 1420 |
id: contactDetailsPersonal |
| 1421 |
anchors { |
| 1422 |
left: parent.left |
| 1423 |
right: parent.right |
| 1424 |
bottom: parent.bottom |
| 1425 |
top: parent.top |
| 1426 |
topMargin: p_hideShow? -(searchPanelContacts.height) : 0 |
| 1427 |
sourceComponent: emptyComponent |
| 1428 |
property bool p_isFavorite: false |
| 1429 |
property string p_imagePath: "" |
| 1430 |
property string p_text: "" |
| 1431 |
property string p_contactID: "0" |
| 1432 |
property string p_extStatus: "" |
| 1433 |
property bool p_editMode: false |
| 1434 |
property bool p_isExt: false |
| 1435 |
property bool p_isOutlook: false |
| 1436 |
property bool p_isOsxContact: false |
| 1437 |
property bool p_hideShow: root.width < 600 && contactDetailsPersonal.sourceComponent !== emptyComponent |
| 1438 |
property bool p_isDepartment: false |
| 1439 |
property int p_countPhones: 0 |
| 1440 |
property string p_telephonyStatus: "" |
| 1441 |
property bool p_hasPresence: false |
| 1442 |
onP_editModeChanged: { |
| 1443 |
if (!p_editMode && !root.p_addToExisting) { |
| 1444 |
root.p_phoneNumber = "" |
| 1445 |
if (!p_editMode) { |
| 1446 |
root.p_changed = false |
| 1447 |
if (!p_hideShow) { |
| 1448 |
restartTimerFocus.restart() |
| 1449 |
signal iShowDetailsAction(bool show, string method) |
| 1450 |
signal iEditModeAction(string action, string method) |
| 1451 |
signal iFinishImportAction() |
| 1452 |
onIShowDetailsAction: { |
| 1453 |
xroot.log("contactDetailsPersonal onIShowDetailsAction " + show + " " + method) |
| 1454 |
if (show) { |
| 1455 |
root.p_rightOpened = true |
| 1456 |
root.p_addContact = false |
| 1457 |
root.p_backClicked = false |
| 1458 |
if(contactDetailsPersonal.p_editMode) { |
| 1459 |
root.p_rightOpened = true |
| 1460 |
contactDetailsPersonal.p_editMode = true |
| 1461 |
contactDetailsPersonal.sourceComponent = componentEditContact |
| 1462 |
else { |
| 1463 |
contactDetailsPersonal.sourceComponent = componentContactDetails |
| 1464 |
else { |
| 1465 |
root.p_rightOpened = false |
| 1466 |
root.p_addContact = false |
| 1467 |
root.p_phoneNumbers = undefined |
| 1468 |
if (method === "clickBack") { |
| 1469 |
root.p_backClicked = true |
| 1470 |
root.p_centerSide.p_overflow.visible = true |
| 1471 |
root.aClearSubscribe(); |
| 1472 |
getPersonalDefaultValue.restart(); |
| 1473 |
else if(["IEditModeAction_save", "handlerCreate", "createContact_cancel"].indexOf(method) !== -1) { |
| 1474 |
contactsTabs.aGetDefaultValue(contactDetailsPersonal, dataContactsList); |
| 1475 |
searchPanelContacts.setFocus(); |
| 1476 |
else if (contactDetailsPersonal.p_editMode === true) { |
| 1477 |
contactDetailsPersonal.iEditModeAction("cancel", "aCancelAction") |
| 1478 |
Timer { |
| 1479 |
id: getPersonalDefaultValue |
| 1480 |
interval: 300 |
| 1481 |
onTriggered: { |
| 1482 |
xroot.log('Timer getPersonalDefaultValue in Contacts onTriggered', 4); |
| 1483 |
contactsTabs.aGetDefaultValue(contactDetailsPersonal, dataContactsList); |
| 1484 |
onIEditModeAction: { |
| 1485 |
xroot.log("contactDetailsPersonal onIEditModeAction " + action + " " + method) |
| 1486 |
switch (action) { |
| 1487 |
case "edit": |
| 1488 |
root.p_rightOpened = true |
| 1489 |
contactDetailsPersonal.p_editMode = true |
| 1490 |
contactDetailsPersonal.sourceComponent = componentEditContact |
| 1491 |
break; |
| 1492 |
case "save": |
| 1493 |
xroot.log("onIEditModeAction save: "+dataContactsList.p_subscribeId) |
| 1494 |
if (dataContactsList.p_subscribeId !== "") { |
| 1495 |
root.p_rightOpened = true |
| 1496 |
contactDetailsPersonal.p_editMode = false |
| 1497 |
contactDetailsPersonal.sourceComponent = componentContactDetails |
| 1498 |
restartTimerFocus.restart() |
| 1499 |
else { |
| 1500 |
contactDetailsPersonal.iShowDetailsAction(false, "IEditModeAction_save") |
| 1501 |
break; |
| 1502 |
case "cancel": |
| 1503 |
if (dataContactsList.p_subscribeId !== "") { |
| 1504 |
contactDetailsPersonal.p_editMode = false |
| 1505 |
if (!root.p_addToExisting) { |
| 1506 |
root.p_rightOpened = true |
| 1507 |
contactDetailsPersonal.sourceComponent = componentContactDetails |
| 1508 |
else { |
| 1509 |
if (p_hideShow) { |
| 1510 |
root.p_rightOpened = false |
| 1511 |
else { |
| 1512 |
root.p_rightOpened = true |
| 1513 |
dataContactsList.p_view.currentIndex = -1 |
| 1514 |
contactDetailsPersonal.sourceComponent = emptyComponent |
| 1515 |
restartTimerFocus.restart() |
| 1516 |
else { |
| 1517 |
contactDetailsPersonal.iShowDetailsAction(false, "IEditModeAction_cancel") |
| 1518 |
break; |
| 1519 |
case "add_contact": |
| 1520 |
root.p_dsObject = undefined; |
| 1521 |
root.aClearSubscribe(); |
| 1522 |
dataContactsList.p_view.positionViewAtBeginning() |
| 1523 |
root.p_rightOpened = true |
| 1524 |
root.p_addContact = true |
| 1525 |
contactDetailsPersonal.p_editMode = true |
| 1526 |
contactDetailsPersonal.sourceComponent = componentAddContact |
| 1527 |
break; |
| 1528 |
default: |
| 1529 |
contactDetailsPersonal.p_editMode = false |
| 1530 |
break; |
| 1531 |
if (contactDetailsPersonal.sourceComponent === componentEditContact || contactDetailsPersonal.sourceComponent === componentAddContact) { |
| 1532 |
contactDetailsPersonal.item.iEditModeAction(action) |
| 1533 |
onIFinishImportAction: { |
| 1534 |
if (contactDetailsPersonal.item.p_isImporting) { |
| 1535 |
contactDetailsPersonal.item.p_isImporting = false; |
| 1536 |
Rectangle { |
| 1537 |
id: spacerSideBySidePersonal |
| 1538 |
width: 1 |
| 1539 |
height: parent.height |
| 1540 |
color: !rightSidePersonal.p_showSeparator? kvs.uiScheme.getStyleProperty("color19", 'transparent') : 'transparent' |
| 1541 |
Rectangle { width: parent.width; height: 1; color: "transparent"; anchors.topMargin: 32; anchors.top: parent.top Timer { |
| 1542 |
id: requestMembers |
| 1543 |
interval: 10000 |
| 1544 |
repeat: true |
| 1545 |
onTriggered: { |
| 1546 |
xroot.log('Timer requestMembers in Contacts onTriggered', 4); |
| 1547 |
if (root.p_dsObject!==undefined) { |
| 1548 |
if (root.p_dsObject.hasAction("getDepartmentMembers")) { |
| 1549 |
root.p_handlerDepartmentMembers = root.p_dsObject.action("getDepartmentMembers") |
| 1550 |
else { |
| 1551 |
requestMembers.stop(); |
| 1552 |
root.p_DMObject = [] |
| 1553 |
onRunningChanged: { |
| 1554 |
if (running && root.p_dsObject !== undefined && root.p_dsObject !== null) { |
| 1555 |
if (root.p_dsObject.hasAction("getDepartmentMembers")) { |
| 1556 |
root.p_handlerDepartmentMembers = root.p_dsObject.action("getDepartmentMembers") |
| 1557 |
else { |
| 1558 |
requestMembers.stop(); |
| 1559 |
root.p_DMObject = [] |
| 1560 |
else { |
| 1561 |
root.p_handlerDepartmentMembers = undefined |
Комментарии