From f70be13bf2776f9aef9bfb498ccab486f2689ce7 Mon Sep 17 00:00:00 2001 From: Imesh Chandrasiri Date: Fri, 16 Dec 2016 14:53:51 +0530 Subject: [PATCH 1/2] Common unit for email invite modal for devices screens --- .../invite-modal.hbs | 74 +++++++++++++++++++ .../invite-modal.json | 4 + .../public/css/invite-modal-styles.css | 3 + .../public/js/invite-modal.js | 52 +++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.json create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/css/invite-modal-styles.css create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs new file mode 100644 index 00000000000..5353b4d8dfa --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs @@ -0,0 +1,74 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} + +{{#zone "content"}} + +{{/zone}} + +{{#zone "topCss"}} + {{css "css/invite-modal-styles.css"}} +{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/invite-modal.js"}} +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.json new file mode 100644 index 00000000000..6768fd5bd56 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "index": 10 +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/css/invite-modal-styles.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/css/invite-modal-styles.css new file mode 100644 index 00000000000..696cf70f7ab --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/css/invite-modal-styles.css @@ -0,0 +1,3 @@ +.select2-container{ + color: #000; +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js new file mode 100644 index 00000000000..7f8e42816d7 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js @@ -0,0 +1,52 @@ +/** + * Created by imesh on 16/12/16. + */ + +/** + * Opens a modal popup with input to enter multiple email addresses to send invites + */ +function toggleEmailInvite(){ + $(".modal-content").html($("#invite-by-email-modal").html()); + //$('.modal-content .select2-container').remove(); + $('.modal-content #choose_usr_email').select2({ + tags: true, + tokenSeparators: [",", " "], + createTag: function(term, data) { + var value = term.term; + if(validateEmail(value)) { + return { + id: value, + text: value + }; + } + return null; + } + }); + showPopup(); +} + +function validateEmail(email) { + var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test(email); +} + +/** + * Action to get email object from select2 element + * @returns {boolean} + */ +function sendInvites(){ + var emailObj = $('.modal-content #choose_usr_email').select2('data'), + emailArr = []; + + if(emailObj.length <= 0){ + console.log('no values to print'); + return false; + } + + emailObj.forEach(function(el){ + emailArr.push(el.text); + }) + + hidePopup(); + console.log(emailArr); +} \ No newline at end of file From 765f97f5a0adaaa3637fceca80ace04a1fd64b88 Mon Sep 17 00:00:00 2001 From: Imesh Chandrasiri Date: Mon, 19 Dec 2016 11:27:01 +0530 Subject: [PATCH 2/2] email invite sender changes --- .../invite-modal.hbs | 6 ++++++ .../public/js/invite-modal.js | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs index 5353b4d8dfa..5a435b4ec91 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/invite-modal.hbs @@ -69,6 +69,12 @@ {{css "css/invite-modal-styles.css"}} {{/zone}} + +{{#zone "topJs"}} + +{{/zone}} + + {{#zone "bottomJs"}} {{js "js/invite-modal.js"}} {{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js index 7f8e42816d7..d33527418df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.email.invite-modal/public/js/invite-modal.js @@ -36,7 +36,10 @@ function validateEmail(email) { */ function sendInvites(){ var emailObj = $('.modal-content #choose_usr_email').select2('data'), - emailArr = []; + emailArr = [], + deviceEmailObj = {}; + + console.log(deviceTypeView); if(emailObj.length <= 0){ console.log('no values to print'); @@ -47,6 +50,12 @@ function sendInvites(){ emailArr.push(el.text); }) + deviceEmailObj = { + "deviceType" : deviceTypeView, + "emailList" : emailArr + } + + hidePopup(); - console.log(emailArr); + console.log(deviceEmailObj); } \ No newline at end of file