Commit dd7dcb62 authored by Siddhant Rajagopalan's avatar Siddhant Rajagopalan

made a superselect2 box,validations

parent 91fa14b0
......@@ -1657,8 +1657,8 @@ ORDER BY civicrm_email.is_bulkmail DESC
// Populate the recipients.
$mailing->getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
}
//print_r($params);
//exit;
// print_r($params);
// exit;
return $mailing;
}
......
......@@ -33,7 +33,7 @@
}
else {
//created_id has been set to my id. Does not save without created_id. Needs to made generic based on the user
return {name: "New Mail", visibility: "Public Pages", url_tracking:"1", forward_replies:"0", created_id: "202", auto_responder:"0", open_tracking:"1",
return {visibility: "Public Pages", url_tracking:"1", forward_replies:"0", created_id: "202", auto_responder:"0", open_tracking:"1",
};
}
}
......@@ -45,7 +45,7 @@
//This controller is used in creating new mail and editing current mails
crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) {
crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail, $location) {
//Making some dummy api to see if my from email, reply to email works. To see if all options come in select box
$scope.cool_api= [
......@@ -60,6 +60,7 @@
'reply_mail': 'rajgo94@gmail_3.com'}
];
//setting variables to the values we have got to the api
$scope.submitted = false;
$scope.partialUrl = partialUrl;
$scope.campaignList = CRM.crmMailing.campNames;
$scope.mailList = CRM.crmMailing.civiMails;
......@@ -71,13 +72,54 @@
$scope.currentMailing = selectedMail;
$scope.testGroup = "";
window.ct = $scope.currentMailing;
$scope.param = {};
$scope.mailingForm = function() {
if ($scope.mailing_form.$valid) {
// Submit as normal
} else {
$scope.mailing_form.submitted = true;
}
}
$scope.back = function (){
$location.path( "mailing" );
};
//initializing variables we will use for checkboxes, or for purpose of ng-show
$scope.acttab=0;
$scope.composeS="1";
$scope.trackreplies="0";
if($scope.currentMailing.forward_replies==0 && $scope.currentMailing.auto_responder==0){
$scope.trackreplies="0";
}
else {
$scope.trackreplies="1";
}
$scope.now="1";
$scope.reply = function(){
if($scope.trackreplies==0){
$scope.trackreplies=1;
}
else{
$scope.trackreplies=0;
$scope.currentMailing.forward_replies=0;
$scope.currentMailing.auto_responder=0;
}
}
$scope.recclicked = function(){
$scope.acttab=0;
};
$scope.conclicked = function(){
$scope.acttab=1;
};
$scope.schedclicked = function(){
$scope.acttab=2;
};
//to split the value of selectedMail.scheduled_date into the date and time separately
$scope.scheddate={};
$scope.scheddate.date = "";
......@@ -102,7 +144,7 @@
}
else
return false;
}
};
//filter so we only get headers from mailing component
$scope.isHeader= function(hf){
return hf.component_type == "Header";
......@@ -136,6 +178,19 @@
return ml.is_completed == 1;
};
$scope.upload = function(){
console.log($scope.param.file);
};
$scope.upload_2 = function(){
console.log($scope.param.file_2);
};
$scope.upload_3 = function(){
console.log($scope.param.file_3);
};
$scope.save = function() {
$scope.incGrp=[];
$scope.excGrp=[];
......@@ -268,9 +323,30 @@
return {
restrict : 'AE',
link: function(scope,element, attrs){
function format(item) {
if(!item.id) {
// return `text` for optgroup
return item.text;
}
// return item template
var a = item.id.split(" ");
console.log(a);
if(a[1]=="group" && a[2]=="include")
return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text;
if(a[1]=="group" && a[2]=="exclude")
return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text;
if(a[1]=="mail" && a[2]=="include")
return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text;
if(a[1]=="mail" && a[2]=="exclude")
return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text;
}
$(element).select2({
width:"400px",
placeholder: "Choose Recipients",
formatResult: format,
formatSelection: format,
escapeMarkup: function(m) { return m; }
});
$(element).on('select2-selecting', function(e) {
incGroup.push(e.val);
......@@ -283,55 +359,38 @@
// Used for the select date option. This is used for giving scheduled_date its date value
crmMailing.directive('chsdate',function(){
return {
scope :{
dat : '=send_date'
},
restrict: 'AE',
link: function(scope,element,attrs){
$(element).datepicker({
dateFormat: "yy-mm-dd",
onSelect: function(date) {
$(".ui-datepicker a").removeAttr("href");
scope.dat =date;
var ngModelName = this.attributes['ng-model'].value;
scope[ngModelName] = date;
scope.$apply();
}
});
}
};
});
/*
//browsing controller. to add selected files. not working currently
crmMailing.controller('browse', function($scope){
$scope.fileList = [];
$('#fileupload').bind('fileuploadadd', function(e, data){
// Add the files to the list
numFiles = $scope.fileList.length
for (var i=0; i < data.files.length; ++i) {
var file = data.files[i];
// .$apply to update angular when something else makes changes
$scope.$apply(
$scope.fileList.push({name: file.name})
);
crmMailing.directive('file', function(){
return {
scope: {
file: '='
},
link: function(scope, el, attrs){
el.bind('change', function(event){
var files = event.target.files;
var file = files[0];
scope.file = file ? file.name : undefined;
scope.$apply();
});
}
// Begin upload immediately
data.submit();
});
};
});
//adding directive. to add selected files. not working currently
crmMailing.directive('add',function(){
return {
restrict : 'AE',
link: function(scope,element, attrs){
$(document).ready(function(){
$('#fileupload').fileupload({
dataType: 'json'
});
});
}
};
});
*/
//This controller is used for creating the mailing list. Simply gets all the mailing data from civiAPI
crmMailing.controller('mailingListCtrl', function($scope, crmApi, mailingList) {
$scope.mailingList = mailingList.values;
......@@ -340,5 +399,6 @@
})(angular, CRM.$, CRM._);
/* example of params
[attachFile_1] => Array ( [uri] => /var/www/siddhant/drupal-7.27/sites/default/files/civicrm/custom/blog_2_odt_2c622a7b5e32415a92e81ed97d6554c7.unknown [type] => application/vnd.oasis.opendocument.text [location] => /var/www/siddhant/drupal-7.27/sites/default/files/civicrm/custom/blog_2_odt_2c622a7b5e32415a92e81ed97d6554c7.unknown [description] => dasdas [upload_date] => 20140706105804 [tag] => Array ( ) [attachment_taglist] => Array ( ) )
*/
......@@ -4,19 +4,28 @@
<tr>
<td class="label">Attach Files</td>
<td>
<input type="file"/>
<input type="file" data-file="param.file"/>
</td>
<td>
<button ng-click="upload()" >Upload</button>
</td>
</tr>
<tr>
<td class="label">Attach Files</td>
<td>
<input type="file"/>
<input type="file" data-file="param.file_2"/>
</td>
<td>
<button ng-click="upload_2()" >Upload</button>
</td>
</tr>
<tr>
<td class="label">Attach Files</td>
<td>
<input type="file"/>
<input type="file" data-file="param.file_3"/>
</td>
<td>
<button ng-click="upload_3()" >Upload</button>
</td>
</tr>
......
......@@ -25,9 +25,14 @@ Required Variables: cool_api and currentMailing and eMailing
<tr>
<td class="label">Mailing Subject</td>
<td>
<input type="text" ng-model="currentMailing.subject"/>
<input placeholder="Enter Subject" required name="subject" type="text" ng-model="currentMailing.subject"/>
</td>
</tr>
<tr>
<td class="label" style= "color:red" ng-show="mailing_form.subject.$invalid">
Mailing subject required.
</td>
</tr>
<tr>
<td class="label">Use Template</td>
<td>
......@@ -36,7 +41,7 @@ Required Variables: cool_api and currentMailing and eMailing
</select>
</td>
</tr>
<tr>
<tr ng-show= "false">
<td class="label">I want to</td>
<td class="label">Compose on screen</td>
<td><input type="radio" ng-model="composeS" value="1" /></td>
......@@ -54,7 +59,7 @@ Required Variables: cool_api and currentMailing and eMailing
<div class="crm-accordion-header">Upload Content</div>
<div class="crm-accordion-body" ng-include="partialUrl('uploadContent.html')"></div>
</div>
<div class="crm-accordion-wrapper collapsed">
<div class="crm-accordion-wrapper collapsed" ng-show="false">
<div class="crm-accordion-header">Attachments</div>
<div class="crm-accordion-body" ng-include="partialUrl('attachments.html')"></div>
</div>
......
......@@ -5,11 +5,11 @@ MailingGroup api needs to be improved to bind the chosen groups
-->
<br>
<select multiple chsgroup>
<option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group include" > Include {{grp.title}}</option>
<option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group exclude" > Exclude {{grp.title}}</option>
<option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail include" > Include Mailing {{ml.name}}</option>
<option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail exclude" > Exclude Mailing {{ml.name}}</option>
<select multiple chsgroup ng-model="incGroup">
<option id= "1" ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group include" > {{grp.title}} </option>
<option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group exclude" > {{grp.title}} </option>
<option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail include" > {{ml.name}} </option>
<option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail exclude" > {{ml.name}} </option>
</select>
<br> <br>
......
......@@ -2,43 +2,47 @@
Controller: MailCtrl
Submit Mailing is not functional yet
-->
<style>
.crm-container .ng-invalid {
border: 1px solid black;
}
</style>
<div class="crm-block crm-form-block ">
<form name="mailing_form" class="ng-valid" novalidate ng-submit="mailingForm()">
<div ui-jq="tabs" id="alltabs">
<ul>
<li><a href="#acttab-0">Recipients</a></li>
<li><a href="#acttab-1">Content</a></li>
<li><a href="#acttab-2">Schedule and Send</a></li>
<li><a href="#acttab-0" ng-click= "recclicked()">Recipients</a></li>
<li><a href="#acttab-1" ng-click= "conclicked()">Content</a></li>
<li><a href="#acttab-2" ng-click= "schedclicked()">Schedule and Send</a></li>
</ul>
<div id="acttab-0">
<div ng-include="partialUrl('recipient.html')"></div>
<a nexttab class="button" ><span>Next</span></a>
<a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
<a ng-href="#/mailing" class="button"><span>Cancel</span></a>
<button nexttab type= "button"><span>Next</span></button>
<button ng-click="save()" ng-disabled="mailing_form.$invalid" type= "submit"><span>Save and Continue Later</span></button>
<button ng-click="back()"><span>Cancel</span></button>
<br><br>
</div>
<div id="acttab-1">
<div ng-include="partialUrl('content.html')"></div>
<br>
<a prevtab class="button" ><span>Previous</span></a>
<a nexttab class="button" ><span>Next</span></a>
<a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
<a ng-href="#/mailing" class="button"><span>Cancel</span></a>
<button prevtab type= "button"><span>Previous</span></button>
<button nexttab type= "button"><span>Next</span></button>
<button ng-click="save()" ng-disabled="mailing_form.$invalid" type="submit"><span>Save and Continue Later</span></button>
<button ng-click="back()" ><span>Cancel</span></button>
<br><br>
</div>
<div id="acttab-2">
<div ng-include="partialUrl('send.html')"></div>
<br>
<a prevtab class="button" ><span>Previous</span></a>
<a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
<a class="button"><span>Submit Mailing</span></a>
<a ng-href="#/mailing" class="button"><span>Cancel</span></a>
<button prevtab type="button" ><span>Previous</span></button>
<button ng-click="save()" ng-disabled="mailing_form.$invalid" type= "submit"><span>Save and Continue Later</span></button>
<button> <span>Submit Mailing</span></button>
<button ng-click="back()" ><span>Cancel</span></button>
<br><br>
</div>
</div>
</div>
</form>
......@@ -4,7 +4,9 @@ Required vars: currentMailing
The editor has to be added. Currently just a simple text editor
-->
<br>
&nbsp &nbsp &nbsp &nbsp
<textarea readonly ng-model="currentMailing.body_html" style="width: 600px; height: 300px;"></textarea>
<br> <br>
<iframe width="80%" height="300" src="/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_991" >
</iframe>
<!--/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_991
/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_7748
-->
......@@ -8,11 +8,16 @@ Remove duplicates not functional
<table class="form-layout-compressed">
<tbody>
<tr>
<td class="label">Name your Mailing</td>
<td class="label">Name your Mailing *</td>
<td>
<input type="text" ng-model="currentMailing.name"/>
<input placeholder="New Mail" name = "name" type="text" required ng-model="currentMailing.name"/>
</td>
</tr>
<tr>
<td class="label" style= "color:red" ng-show="mailing_form.name.$invalid">
Your name is required.
</td>
</tr>
<tr>
<td class="label">Campaign</td>
<td class="addRow">
......
......@@ -2,7 +2,7 @@
Controller: MailCtrl
Required vars: currentMailing
-->
<!--<script src="../../packages/jquery/plugins/jquery.validate.min.js"><script>-->
<br>
<table class="form-layout-compressed">
<tbody>
......@@ -17,7 +17,7 @@ Required vars: currentMailing
<tr ng-show="now==0">
<td class="label">Schedule Mailing</td>
<td>
<input type="text" chsdate ng-model="scheddate.date">
<input type="text" ng-model="scheddate.date" chsdate >
</td>
<td class="label" >Time</td>
<td>
......
......@@ -41,7 +41,7 @@ Required vars: currentMailing
</tr>
<tr>
<td>
<input type="checkbox" ng-model="trackreplies" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
<input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
</td>
</tr>
<tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment