Need to create a extension with the JavaScript, Templates, files and need to do some configuration in Model files.
Tab name ResaleCertificate and JavaScript file, View file, Model file, Router file, tpl file.
//ResaleCertificate.js
define(‘ResaleCertificate’,
[
‘ResaleCertificate.Router’,
‘ResaleCertificate.Model’,
‘SC.Configuration’,
‘Utils’,
‘Profile.Model’,
‘jQuery’,
‘underscore’
],
function(Router, ResaleCertificate, Configuration, Utils, ProfileModel, jQuery, _) {
‘use strict’;
console.log(‘ResaleCertificate’)
return {
Router: Router,
MenuItems: {
id: ‘resalecertificate’,
name: _(‘Resale Certificate’).translate(),
index: 8,
children: [{
id: ‘uploadcertificate’,
name: _(‘Upload Certificate’).translate(),
url: ‘uploadcertificate’,
index: 1
}
]
},
mountToApp: function(application) {
var isEnabled = false;
var profile = ProfileModel.getInstance();
var model = new ResaleCertificate();
var promise = jQuery.Deferred();
isEnabled = (profile && (profile.get(‘UploadCertificate’) == ‘T’) && (profile.get(‘DontUploadCertificate’) == ‘T’)) || false
//console.log(“id”, profile.get(“addresses”).models);
return new Router({ application: application, isEnabled: isEnabled});
}
};
});
//ResaleCertificate.View
define('ResaleCertificate.View',
[
'Backbone',
'ResaleCertificate.Model',
'ResaleCertificate.tpl',
'GlobalViews.Message.View',
'jQuery',
'underscore',
'Profile.Model'
],
function(Backbone,
ResaleCertificateModel,
ResaleCertificate_tpl,
MessageView,
jQuery,
_,
ProfileModel
){
'use script';
return Backbone.View.extend({
template: ResaleCertificate_tpl,
title: _('Upload Certificate').translate(),
page_header: _('Upload Certificate').translate(),
events: {
'change #register-country': 'CountryUS',
},
attributes: {
'class': 'uploadcertificate'
},
changeName : function(){
var profile = ProfileModel.getInstance();
var changeAddress = _.filter(profile.get("addresses").models, function(address){
if(address.get("defaultbilling") == "T"){
//console.log(address);
return address;
}
})
},
CountryUS : function()
{
var x = document.getElementById("register-country").value;
$("custentity1" && "custentity2" && "US").show();
if (x === "US" && (custentity1 === checked || custentity2 === checked))
{
$("custentity1" && "custentity2" && "US").show();
}
else {
$("custentity1" && "custentity2" && "US").hide();
}
},
initialize: function(options) {
this.options = options;
this.additional = {
upload: ProfileModel.getInstance().get('UploadCertificate') ? ProfileModel.getInstance().get('UploadCertificate') : false,
donotUpload: ProfileModel.getInstance().get('DontUploadCertificate') ? ProfileModel.getInstance().get('DontUploadCertificate') : false,
}
},
getSelectedMenu: function() {
return 'uploadcertificate';
},
//@method getBreadcrumbPages
getBreadcrumbPages: function() {
return {
text: this.title,
href: '/uploadcertificate'
};
},
getContext: function() {
// @class Case.Create.View.Context
return {
//@property {String} pageHeader
pageHeader: this.page_header
//@property {Boolean} isDefaultShippingAddress
// isDefaultBillingAddress: this.model.get('defaultbilling') === 'T'
}
}
})
})
//ResaleCertificate.Router
define('ResaleCertificate.Router',
[
'Backbone',
'Profile.Model',
'ResaleCertificate.Model',
'ResaleCertificate.View',
'Utils',
'jQuery',
'GlobalViews.Message.View'
],
function(
Backbone,
ProfileModel,
ResaleCertificateModel,
ResaleCertificateView,
Utils,
jQuery,
MessageView
)
{
'use strict';
return Backbone.Router.extend({
initialize: function(Options) {
this.application = Options.application;
this.isEnabled = Options.isEnabled;
},
routes: {
'uploadcertificate': 'UploadCertificate'
},
UploadCertificate: function(options) {
var self = this;
var view = new ResaleCertificateView({
application: this.application,
isEnabled: self.isEnabled,
});
view.showContent();
}
});
});