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