From 0e383d8dd59e851181a40588e3e651af0c095478 Mon Sep 17 00:00:00 2001 From: vtiger <balaji@vtiger.com> Date: Thu, 28 Dec 2017 14:55:20 +0530 Subject: [PATCH] Mobile web app issues --- .../v7/modules/Mobile/simple/Vtiger/Edit.tpl | 22 +++++------ .../modules/Mobile/simple/Vtiger/js/Edit.js | 37 +++++++++---------- .../modules/Mobile/simple/Vtiger/js/List.js | 3 +- .../modules/Mobile/modules/Mobile/api.v1.php | 1 + .../Mobile/modules/Mobile/api/ws/Describe.php | 8 ++++ 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/layouts/v7/modules/Mobile/simple/Vtiger/Edit.tpl b/layouts/v7/modules/Mobile/simple/Vtiger/Edit.tpl index d11c897b1..a4ddf0523 100644 --- a/layouts/v7/modules/Mobile/simple/Vtiger/Edit.tpl +++ b/layouts/v7/modules/Mobile/simple/Vtiger/Edit.tpl @@ -13,7 +13,7 @@ <script type="text/javascript" src="../../{$TEMPLATE_WEBPATH}/Vtiger/js/Edit.js"></script> {literal} -<form name="editForm" id="field-edit-form" ng-submit="saveThisRecord()" ng-controller="VtigerEditController"> +<form name="editForm" id="field-edit-form" ng-submit="saveThisRecord(editForm)" ng-controller="VtigerEditController"> <header md-page-header fixed-top> <md-toolbar> <div class="md-toolbar-tools actionbar"> @@ -58,7 +58,7 @@ <label ng-if="field.name == 'taskstatus'">Task Status</label> <label ng-if="field.name == 'eventstatus'">Event Status</label> <label ng-if="field.name != 'taskstatus' && field.name != 'eventstatus'">{{field.label}}</label> - <md-select ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory"> + <md-select name="{{field.name}}" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory"> <md-option ng-value="opt.value" ng-repeat="opt in field.type.picklistValues">{{opt.label}}</md-option> </md-select> </div> @@ -72,7 +72,7 @@ <label ng-if="field.name == 'taskstatus'">Task Status</label> <label ng-if="field.name == 'eventstatus'">Event Status</label> <label ng-if="field.name != 'taskstatus' && field.name != 'eventstatus'">{{field.label}}</label> - <md-select ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory"> + <md-select name="{{field.name}}" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory"> <md-option ng-value="opt.value" ng-repeat="opt in field.type.picklistValues">{{opt.label}}</md-option> </md-select> </div> @@ -84,7 +84,7 @@ <md-input-container ng-switch-when="owner"> <div class="input-group-addon"> <label>{{field.label}}</label> - <md-select ng-model="field.raw" aria-label="{{field.label}}"> + <md-select name="{{field.name}}" ng-model="field.raw" aria-label="{{field.label}}"> <md-optgroup label="Users" aria-label="Users"> <md-option ng-value="user_id" ng-repeat="(user_id, user) in field.type.picklistValues.users">{{user}}</md-option> </md-optgroup> @@ -101,7 +101,7 @@ <div ng-switch-when="reference" style="padding-bottom: 16px;"> <div class="input-group-addon"> <label>{{field.label}}</label> - <md-autocomplete flex + <md-autocomplete name="{{field.name}}" flex ng-model="field.raw" md-search-text="field.valueLabel" md-items="item in getMatchedReferenceFields(field.valueLabel, field)" @@ -125,7 +125,7 @@ <md-input-container ng-switch-when="multipicklist"> <div class="input-group-addon"> <label>{{field.label}}</label> - <md-chips ng-model="field.valuelabel" md-autocomplete-snap md-require-match> + <md-chips name="{{field.name}}" ng-model="field.valuelabel" md-autocomplete-snap md-require-match> <md-autocomplete aria-label="{{field.name}}" md-input-name="field.name" md-search-text="field.valuelabel" @@ -150,7 +150,7 @@ <div layout="row"> <span class="mdi mdi-calendar editIcon"></span> <div flex="90"> - <input type="date" ng-model="field.raw"> + <input name="{{field.name}}" type="date" aria-label="Date Field UI" ng-model="field.raw"> </div> </div> </div> @@ -165,8 +165,8 @@ <div layout="row" class="input-group-addon" flex> <span class="mdi mdi-clock editIcon"></span> <div flex="90"> - <input mdc-datetime-picker ng-if="userinfo.hour_format == '12'" date="false" time="true" type="text" format="hh:mm a" short-time="true" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory" placeholder="Time"> - <input mdc-datetime-picker ng-if="userinfo.hour_format == '24'" date="false" time="true" type="text" format="HH:mm" short-time="false" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory" placeholder="Time"> + <input name="{{field.name}}" mdc-datetime-picker ng-if="userinfo.hour_format == '12'" date="false" time="true" type="text" format="hh:mm a" short-time="true" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory" placeholder="Time"> + <input name="{{field.name}}" mdc-datetime-picker ng-if="userinfo.hour_format == '24'" date="false" time="true" type="text" format="HH:mm" short-time="false" ng-model="field.raw" aria-label="{{field.label}}" ng-required="field.mandatory" placeholder="Time"> </div> </div> </div> @@ -176,7 +176,7 @@ </md-input-container> <!--*************Checkbox /Boolean Box UI *********************--> <md-input-container ng-switch-when="boolean"> - <md-checkbox class="md-primary edit-checkbox" name="{{field.name}}" ng-model="field.raw" aria-label="{{field.name}}" ng-required="field.mandatory"> + <md-checkbox name="{{field.name}}" class="md-primary edit-checkbox" name="{{field.name}}" ng-model="field.raw" aria-label="{{field.name}}" ng-required="field.mandatory"> {{field.label}} </md-checkbox> <div ng-messages="editForm.{{field.name}}.$error"> @@ -186,7 +186,7 @@ <!--************* TEXT AREA *********************--> <md-input-container ng-switch-when="text"> <label>{{field.label}}</label> - <textarea ng-model="field.raw" rows="4" md-select-on-focus></textarea> + <textarea name="{{field.name}}" ng-model="field.raw" rows="4" md-select-on-focus></textarea> <div ng-messages="editForm.{{field.name}}.$error"> <div ng-show="field.mandatory" ng-message="required"> Mandatory Field.</div> </div> diff --git a/layouts/v7/modules/Mobile/simple/Vtiger/js/Edit.js b/layouts/v7/modules/Mobile/simple/Vtiger/js/Edit.js index 6c52a3180..567fff88d 100644 --- a/layouts/v7/modules/Mobile/simple/Vtiger/js/Edit.js +++ b/layouts/v7/modules/Mobile/simple/Vtiger/js/Edit.js @@ -62,7 +62,7 @@ mobileapp.controller('VtigerEditController', function ($scope, $api, $mdToast, $ } return field; }; - var ignorefields = ['duration_hours','duration_minutes','notime','starred','tags','modifiedby','reminder_time','imagename','taxclass','isconvertedfromlead','donotcall']; + var ignorefields = ['notime','starred','tags','modifiedby','reminder_time','imagename','taxclass','isconvertedfromlead','donotcall']; //Function to prepare create data. var prepareCreateData = function(newRecord, record){ @@ -147,22 +147,6 @@ mobileapp.controller('VtigerEditController', function ($scope, $api, $mdToast, $ value = field.raw; value = moment.utc(value).format('HH:mm:ss'); break; - - case 'reference' : - if(value && field.editable){ - value = field.raw; - var webservice_value = value.split('x'); - value = webservice_value[1]; - } - break; - - case 'owner' : - if(value && field.editable){ - value = field.raw; - var webservice_value = value.split('x'); - value = webservice_value[1]; - } - break; } if(field.editable){ $scope.editdata[field.name] = value; @@ -170,13 +154,26 @@ mobileapp.controller('VtigerEditController', function ($scope, $api, $mdToast, $ } }; - $scope.saveThisRecord = function () { + $scope.isValid = function(form){ + if(!form.$valid) { + return false; + } + return true; + }; + + $scope.saveThisRecord = function (editForm) { + if(!$scope.isValid(editForm)) { + var toast = $mdToast.simple().content('Mandatory Fields Missing').position($scope.getToastPosition()).hideDelay(1000); + $mdToast.show(toast); + return; + } $scope.processEditData($scope.fieldsData); $api('saveRecord', {module: $scope.module, record: $scope.record, values: $scope.editdata}, function (e, r) { if (r) { + //split the ws id to get actual record id to fetch. + var id = r.record.id.split('x')[1]; var toast = $mdToast.simple().content('Record Saved Successfully!').position($scope.getToastPosition()).hideDelay(1000); - $mdToast.show(toast); - window.location.href = "index.php?module="+$scope.module+"&view=Detail&record="+r.id+"&app="+$scope.selectedApp; + window.location.href = "index.php?module="+$scope.module+"&view=Detail&record="+id+"&app="+$scope.selectedApp; } else { var toast = $mdToast.simple().content('Some thing went wrong ! \n Save is not Succesfull.').position($scope.getToastPosition()).hideDelay(1000); $mdToast.show(toast); diff --git a/layouts/v7/modules/Mobile/simple/Vtiger/js/List.js b/layouts/v7/modules/Mobile/simple/Vtiger/js/List.js index b94fc382e..ebc2a504c 100644 --- a/layouts/v7/modules/Mobile/simple/Vtiger/js/List.js +++ b/layouts/v7/modules/Mobile/simple/Vtiger/js/List.js @@ -24,13 +24,12 @@ mobileapp.controller('VtigerListController', function ($scope, $api, $mdDialog) // To fetch Module Filters $api('fetchModuleFilters', {module: $scope.module}, function (e, r) { $scope.filters = r.filters; - $scope.moduleLabel = r.moduleLabel; $scope.loadRecords(); }); // To fetch data from service with the given params $scope.loadRecords = function () { - $scope.pageTitle = $scope.moduleLabel; + $scope.pageTitle = $scope.module; $api('listModuleRecords', {module: $scope.module, filterid: $scope.selectedFilter, page: $scope.page, orderBy: $scope.orderBy, sortOrder: $scope.sortOrder}, function (e, r) { $scope.records = r.records; $scope.selectedFilter = r.selectedFilter; diff --git a/pkg/vtiger/modules/Mobile/modules/Mobile/api.v1.php b/pkg/vtiger/modules/Mobile/modules/Mobile/api.v1.php index 543da0e3e..c1003c66d 100644 --- a/pkg/vtiger/modules/Mobile/modules/Mobile/api.v1.php +++ b/pkg/vtiger/modules/Mobile/modules/Mobile/api.v1.php @@ -21,6 +21,7 @@ class Mobile_APIV1_Controller { 'fetchRecord' => array('file' => '/api/ws/FetchRecord.php', 'class' => 'Mobile_WS_FetchRecord'), 'fetchRecordWithGrouping' => array('file' => '/api/ws/FetchRecordWithGrouping.php', 'class' => 'Mobile_WS_FetchRecordWithGrouping'), 'fetchRecordsWithGrouping' => array('file' => '/api/ws/FetchRecordsWithGrouping.php', 'class' => 'Mobile_WS_FetchRecordsWithGrouping'), + 'fetchReferenceRecords' => array('file' => '/api/ws/FetchReferenceRecords.php', 'class' => 'Mobile_WS_FetchReferenceRecords'), 'describe' => array('file' => '/api/ws/Describe.php', 'class' => 'Mobile_WS_Describe'), 'saveRecord' => array('file' => '/api/ws/SaveRecord.php', 'class' => 'Mobile_WS_SaveRecord'), 'syncModuleRecords' => array('file' => '/api/ws/SyncModuleRecords.php', 'class' => 'Mobile_WS_SyncModuleRecords'), diff --git a/pkg/vtiger/modules/Mobile/modules/Mobile/api/ws/Describe.php b/pkg/vtiger/modules/Mobile/modules/Mobile/api/ws/Describe.php index 77ba32205..00d04b56a 100644 --- a/pkg/vtiger/modules/Mobile/modules/Mobile/api/ws/Describe.php +++ b/pkg/vtiger/modules/Mobile/modules/Mobile/api/ws/Describe.php @@ -44,6 +44,14 @@ class Mobile_WS_Describe extends Mobile_WS_Controller { $field['type']['picklistValues']['users'] = $users; $field['type']['picklistValues']['groups'] = $groups; } + if($fieldModel && $fieldModel->get('name') == 'salutationtype') { + $values = $fieldModel->getPicklistValues(); + $picklistValues = array(); + foreach($values as $value => $label) { + $picklistValues[] = array('value'=>$value, 'label'=>$label); + } + $field['type']['picklistValues'] = $picklistValues; + } $newFields[] = $field; } $fields=null; -- GitLab