Commit 09e78ba1 authored by Vikas's avatar Vikas

Added TAP script for registering widget in Organization detail view

parent 25a04abf
var Accounts_Component_EnrichWidget = VTAP.Component.Core.extend({
created() {
VTAP.Component.Register('DETAIL_SUMMARY_WIDGET', {}, VTAP.Component.Load('AbstractAPIWidget', 'Accounts'), {module:'Accounts'});
VTAP.Component.Register('LIST_ADVANCED_SETTING', {name:'Abstract API', 'clickHandler':this.abstractAPIPopup}, '', {module:'Accounts'});
},
methods : {
abstractAPIPopup() {
VTAP.Utility.ShowPopup({
component : VTAP.Component.Load('AbstractSettings', 'Accounts'),
componentData : {},
modalOnModalMode : true
})
}
}
});
var Accounts_Component_AbstractSettings = VTAP.Component.Core.extend({
data() {
return {
apikey : ''
}
},
created() {
VTAP.AppData.Get('Accounts', {data_key:'abstract_apikey'}, (error, response) => {
if(response) {
this.apikey = response[0].data_value;
}
});
},
methods : {
save() {
if(this.apikey != '') {
VTAP.AppData.Save('Accounts', {data_key:'abstract_apikey', data_value:this.apikey}, (error, response) => {
if(response) VTAP.Utilty.ShowSuccessNotification('updated key');
})
}
}
},
template :
`<b-modal size="lg" @ok="save()" title="AbstractAPI settings">
<div class="row">
<div class="col-4">API Key</div>
<div class="col-6">
<input type="text" v-model="apikey" class="form-control"/>
</div>
</div>
</b-modal>`
})
var Accounts_Component_AbstractAPIWidget = VTAP.Component.Core.extend({
props : ['record'],
data() {
return {
enrichData : {}
}
},
methods : {
getEnrichData() {
if(this.record.email_domain == '') {
VTAP.Utility.ShowErrorNotification('Please add a valid email domain!!');
return;
}
VTAP.CustomApi.Get('get_abstractapi_company_enrich', {domain: this.record.email_domain}, (error, response) => {
if(response && response.content) {
this.enrichData = JSON.parse(response.content);
}
});
}
},
template :
`<div class="d-flex justify-content-center align-items-center" style="min-height:150px;background-color:white;">
<div>
<div v-if="Object.keys(enrichData).length == 0">
<div>
Get enrich data from <a target="_blank" href="https://www.abstractapi.com/api/company-enrichment"><img src="https://global-uploads.webflow.com/5ebbd0a566a3996636e55959/5ec2b974e578f93e553425eb_logo-dark.svg" width="100px" height="50px"></a>, click below button
</div>
<div class='d-flex justify-content-center mt-2'>
<button class='btn btn-primary' @click="getEnrichData()">
Enrich data
</button>
</div>
</div>
<div v-else>
<div class='m-2'>
<span class="pr-2"><img src="https://global-uploads.webflow.com/5ebbd0a566a3996636e55959/5ec2b974e578f93e553425eb_logo-dark.svg" width="100px" height="50px"></span>
Company Enrichment
</div>
<table class="table">
<tr v-for="(data, index) in enrichData">
<th>{{index}}</th>
<td>{{data}}</td>
</tr>
</table>
</div>
</div>
</div>`
});
\ No newline at end of file
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