diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_crm_partner_assign/static | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_crm_partner_assign/static')
| -rw-r--r-- | addons/website_crm_partner_assign/static/description/icon.png | bin | 0 -> 13041 bytes | |||
| -rw-r--r-- | addons/website_crm_partner_assign/static/description/icon.svg | 1 | ||||
| -rw-r--r-- | addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js | 276 |
3 files changed, 277 insertions, 0 deletions
diff --git a/addons/website_crm_partner_assign/static/description/icon.png b/addons/website_crm_partner_assign/static/description/icon.png Binary files differnew file mode 100644 index 00000000..f8d1e76e --- /dev/null +++ b/addons/website_crm_partner_assign/static/description/icon.png diff --git a/addons/website_crm_partner_assign/static/description/icon.svg b/addons/website_crm_partner_assign/static/description/icon.svg new file mode 100644 index 00000000..9fe38ef5 --- /dev/null +++ b/addons/website_crm_partner_assign/static/description/icon.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="70" height="70" viewBox="0 0 70 70"><defs><path id="a" d="M4 0h61c4 0 5 1 5 5v60c0 4-1 5-5 5H4c-3 0-4-1-4-5V5c0-4 1-5 4-5z"/><linearGradient id="c" x1="100%" x2="0%" y1="0%" y2="100%"><stop offset="0%" stop-color="#7CC098"/><stop offset="100%" stop-color="#5F8A71"/></linearGradient><path id="d" d="M42.525 39.25H32.346l.228 1.125h9.32c.534 0 .93.503.812 1.03l-.191.854a1.971 1.971 0 0 1 1.096 1.772c0 1.097-.886 1.985-1.973 1.969-1.035-.015-1.887-.866-1.915-1.914a1.975 1.975 0 0 1 .583-1.461h-7.28c.361.357.585.855.585 1.406 0 1.119-.921 2.02-2.037 1.967-.991-.047-1.797-.857-1.849-1.86a1.973 1.973 0 0 1 .974-1.814l-2.44-12.074h-2.426a.839.839 0 0 1-.833-.844v-.562c0-.466.373-.844.833-.844h3.56c.396 0 .737.282.817.675l.318 1.575h13.638c.535 0 .931.503.813 1.03l-1.641 7.313a.836.836 0 0 1-.813.657zm-3.358-5.344H37.5V32.5a.559.559 0 0 0-.556-.563h-.555a.559.559 0 0 0-.556.563v1.406h-1.666a.559.559 0 0 0-.556.563v.562c0 .31.249.563.556.563h1.666V37c0 .31.25.562.556.562h.555A.559.559 0 0 0 37.5 37v-1.406h1.667a.559.559 0 0 0 .555-.563v-.562a.559.559 0 0 0-.555-.563zM26.385 8l-5.9 8.058 9.51 3.036-1.28-3.953a22.208 22.208 0 0 1 7.2-1.203c11.135 0 20.316 8.182 21.904 18.866l3.228-2.94c-2.799-11.282-12.995-19.668-25.132-19.668a25.8 25.8 0 0 0-8.365 1.394L26.385 8zm-8.44 9.452C13.046 22.167 10 28.769 10 36.088c0 7.763 3.434 14.745 8.861 19.496l-2.54 2.807 9.93 1.07-2.12-9.739-2.768 3.074a22.075 22.075 0 0 1-7.6-16.708 22.073 22.073 0 0 1 8.326-17.319l-2.922-.935-1.223-.382zM60.97 32.766l-7.39 6.702 4.068.879c-1.98 10.21-10.933 17.891-21.733 17.891-2.858 0-5.591-.528-8.097-1.508l.916 4.258A25.918 25.918 0 0 0 35.914 62c12.565 0 23.05-8.988 25.4-20.87l3.686.782-4.03-9.146z"/><path id="e" d="M42.525 37.25H32.346l.228 1.125h9.32c.534 0 .93.503.812 1.03l-.191.854a1.971 1.971 0 0 1 1.096 1.772c0 1.097-.886 1.985-1.973 1.969-1.035-.015-1.887-.866-1.915-1.914a1.975 1.975 0 0 1 .583-1.461h-7.28c.361.357.585.855.585 1.406 0 1.119-.921 2.02-2.037 1.967-.991-.047-1.797-.857-1.849-1.86a1.973 1.973 0 0 1 .974-1.814l-2.44-12.074h-2.426a.839.839 0 0 1-.833-.844v-.562c0-.466.373-.844.833-.844h3.56c.396 0 .737.282.817.675l.318 1.575h13.638c.535 0 .931.503.813 1.03l-1.641 7.313a.836.836 0 0 1-.813.657zm-3.358-5.344H37.5V30.5a.559.559 0 0 0-.556-.563h-.555a.559.559 0 0 0-.556.563v1.406h-1.666a.559.559 0 0 0-.556.563v.562c0 .31.249.563.556.563h1.666V35c0 .31.25.562.556.562h.555A.559.559 0 0 0 37.5 35v-1.406h1.667a.559.559 0 0 0 .555-.563v-.562a.559.559 0 0 0-.555-.563zM26.385 6l-5.9 8.058 9.51 3.036-1.28-3.953a22.208 22.208 0 0 1 7.2-1.203c11.135 0 20.316 8.182 21.904 18.866l3.228-2.94C58.248 16.582 48.052 8.196 35.915 8.196A25.8 25.8 0 0 0 27.55 9.59L26.385 6zm-8.44 9.452C13.046 20.167 10 26.769 10 34.088c0 7.763 3.434 14.745 8.861 19.496l-2.54 2.807 9.93 1.07-2.12-9.739-2.768 3.074a22.075 22.075 0 0 1-7.6-16.708 22.073 22.073 0 0 1 8.326-17.319l-2.922-.935-1.223-.382zM60.97 30.766l-7.39 6.702 4.068.879c-1.98 10.21-10.933 17.891-21.733 17.891-2.858 0-5.591-.528-8.097-1.508l.916 4.258A25.918 25.918 0 0 0 35.914 60c12.565 0 23.05-8.988 25.4-20.87l3.686.782-4.03-9.146z"/></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><g mask="url(#b)"><path fill="url(#c)" d="M0 0H70V70H0z"/><path fill="#FFF" fill-opacity=".383" d="M4 1h61c2.667 0 4.333.667 5 2V0H0v3c.667-1.333 2-2 4-2z"/><path fill="#393939" d="M38.386 69H4c-2 0-4-1-4-4V36.453l14.194-16.398 3.743-4.473 6.001-3.975C38.52 11.29 47.207 12.422 50 15c1.762 1.626 5.428 5.916 10.998 12.868v3.175l3.838 8.813-8.77 9.88-1.372 2.168L38.386 69z" opacity=".324"/><path fill="#000" fill-opacity=".383" d="M4 69h61c2.667 0 4.333-1 5-3v4H0v-4c.667 2 2 3 4 3z"/><use fill="#000" fill-opacity=".3" fill-rule="nonzero" xlink:href="#d"/><use fill="#FFF" fill-rule="nonzero" xlink:href="#e"/></g></g></svg>
\ No newline at end of file diff --git a/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js new file mode 100644 index 00000000..3cce8485 --- /dev/null +++ b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js @@ -0,0 +1,276 @@ +odoo.define('crm.partner_assign', function (require) { +'use strict'; + +var publicWidget = require('web.public.widget'); +var time = require('web.time'); + +publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({ + selector: '#wrapwrap:has(.interested_partner_assign_form, .desinterested_partner_assign_form, .opp-stage-button, .new_opp_form)', + events: { + 'click .interested_partner_assign_confirm': '_onInterestedPartnerAssignConfirm', + 'click .desinterested_partner_assign_confirm': '_onDesinterestedPartnerAssignConfirm', + 'click .opp-stage-button': '_onOppStageButtonClick', + 'change .edit_contact_form .country_id': '_onEditContactFormChange', + 'click .edit_contact_confirm': '_onEditContactConfirm', + 'click .new_opp_confirm': '_onNewOppConfirm', + 'click .edit_opp_confirm': '_onEditOppConfirm', + 'change .edit_opp_form .next_activity': '_onChangeNextActivity', + 'click div.input-group span.fa-calendar': '_onCalendarIconClick', + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @private + * @param {jQuery} $btn + * @param {function} callback + * @returns {Promise} + */ + _buttonExec: function ($btn, callback) { + // TODO remove once the automatic system which does this lands in master + $btn.prop('disabled', true); + return callback.call(this).guardedCatch(function () { + $btn.prop('disabled', false); + }); + }, + /** + * @private + * @returns {Promise} + */ + _confirmInterestedPartner: function () { + return this._rpc({ + model: 'crm.lead', + method: 'partner_interested', + args: [ + [parseInt($('.interested_partner_assign_form .assign_lead_id').val())], + $('.interested_partner_assign_form .comment_interested').val() + ], + }).then(function () { + window.location.href = '/my/leads'; + }); + }, + /** + * @private + * @returns {Promise} + */ + _confirmDesinterestedPartner: function () { + return this._rpc({ + model: 'crm.lead', + method: 'partner_desinterested', + args: [ + [parseInt($('.desinterested_partner_assign_form .assign_lead_id').val())], + $('.desinterested_partner_assign_form .comment_desinterested').val(), + $('.desinterested_partner_assign_form .contacted_desinterested').prop('checked'), + $('.desinterested_partner_assign_form .customer_mark_spam').prop('checked'), + ], + }).then(function () { + window.location.href = '/my/leads'; + }); + }, + /** + * @private + * @param {} + * @returns {Promise} + */ + _changeOppStage: function (leadID, stageID) { + return this._rpc({ + model: 'crm.lead', + method: 'write', + args: [[leadID], { + stage_id: stageID, + }], + context: _.extend({website_partner_assign: 1}), + }).then(function () { + window.location.reload(); + }); + }, + /** + * @private + * @returns {Promise} + */ + _editContact: function () { + return this._rpc({ + model: 'crm.lead', + method: 'update_contact_details_from_portal', + args: [[parseInt($('.edit_contact_form .opportunity_id').val())], { + partner_name: $('.edit_contact_form .partner_name').val(), + phone: $('.edit_contact_form .phone').val(), + mobile: $('.edit_contact_form .mobile').val(), + email_from: $('.edit_contact_form .email_from').val(), + street: $('.edit_contact_form .street').val(), + street2: $('.edit_contact_form .street2').val(), + city: $('.edit_contact_form .city').val(), + zip: $('.edit_contact_form .zip').val(), + state_id: parseInt($('.edit_contact_form .state_id').find(':selected').attr('value')), + country_id: parseInt($('.edit_contact_form .country_id').find(':selected').attr('value')), + }], + }).then(function () { + window.location.reload(); + }); + }, + /** + * @private + * @returns {Promise} + */ + _createOpportunity: function () { + return this._rpc({ + model: 'crm.lead', + method: 'create_opp_portal', + args: [{ + contact_name: $('.new_opp_form .contact_name').val(), + title: $('.new_opp_form .title').val(), + description: $('.new_opp_form .description').val(), + }], + }).then(function (response) { + if (response.errors) { + $('#new-opp-dialog .alert').remove(); + $('#new-opp-dialog div:first').prepend('<div class="alert alert-danger">' + response.errors + '</div>'); + return Promise.reject(response); + } else { + window.location = '/my/opportunity/' + response.id; + } + }); + }, + /** + * @private + * @returns {Promise} + */ + _editOpportunity: function () { + return this._rpc({ + model: 'crm.lead', + method: 'update_lead_portal', + args: [[parseInt($('.edit_opp_form .opportunity_id').val())], { + date_deadline: this._parse_date($('.edit_opp_form .date_deadline').val()), + expected_revenue: parseFloat($('.edit_opp_form .expected_revenue').val()), + probability: parseFloat($('.edit_opp_form .probability').val()), + activity_type_id: parseInt($('.edit_opp_form .next_activity').find(':selected').attr('data')), + activity_summary: $('.edit_opp_form .activity_summary').val(), + activity_date_deadline: this._parse_date($('.edit_opp_form .activity_date_deadline').val()), + priority: $('input[name="PriorityRadioOptions"]:checked').val(), + }], + }).then(function () { + window.location.reload(); + }); + }, + + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + * @param {Event} ev + */ + _onInterestedPartnerAssignConfirm: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + if ($('.interested_partner_assign_form .comment_interested').val() && $('.interested_partner_assign_form .contacted_interested').prop('checked')) { + this._buttonExec($(ev.currentTarget), this._confirmInterestedPartner); + } else { + $('.interested_partner_assign_form .error_partner_assign_interested').css('display', 'block'); + } + }, + /** + * @private + * @param {Event} ev + */ + _onDesinterestedPartnerAssignConfirm: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + this._buttonExec($(ev.currentTarget), this._confirmDesinterestedPartner); + }, + /** + * @private + * @param {Event} ev + */ + _onOppStageButtonClick: function (ev) { + var $btn = $(ev.currentTarget); + this._buttonExec( + $btn, + this._changeOppStage.bind(this, parseInt($btn.attr('opp')), parseInt($btn.attr('data'))) + ); + }, + /** + * @private + * @param {Event} ev + */ + _onEditContactFormChange: function (ev) { + var countryID = $('.edit_contact_form .country_id').find(':selected').attr('value'); + $('.edit_contact_form .state[country!=' + countryID + ']').css('display', 'none'); + $('.edit_contact_form .state[country=' + countryID + ']').css('display', 'block'); + }, + /** + * @private + * @param {Event} ev + */ + _onEditContactConfirm: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + this._buttonExec($(ev.currentTarget), this._editContact); + }, + /** + * @private + * @param {Event} ev + */ + _onNewOppConfirm: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + this._buttonExec($(ev.currentTarget), this._createOpportunity); + }, + /** + * @private + * @param {Event} ev + */ + _onEditOppConfirm: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + if ($(".edit_opp_form")[0].checkValidity()) { + this._buttonExec($(ev.currentTarget), this._editOpportunity); + } + }, + /** + * @private + * @param {Event} ev + */ + _onChangeNextActivity: function (ev) { + var $selected = $('.edit_opp_form .next_activity').find(':selected'); + if ($selected.attr('activity_summary')) { + $('.edit_opp_form .activity_summary').val($selected.attr('activity_summary')); + } + if ($selected.attr('delay_count')) { + var now = moment(); + var date = now.add(parseInt($selected.attr('delay_count')), $selected.attr('delay_unit')); + $('.edit_opp_form .activity_date_deadline').val(date.format(time.getLangDateFormat())); + } + }, + /** + * @private + * @param {Event} ev + */ + _onCalendarIconClick: function (ev) { + $(ev.currentTarget).closest('div.date').datetimepicker({ + format : time.getLangDateFormat(), + icons: { + time: 'fa fa-clock-o', + date: 'fa fa-calendar', + up: 'fa fa-chevron-up', + down: 'fa fa-chevron-down', + }, + }); + }, + + _parse_date: function (value) { + console.log(value); + var date = moment(value, "YYYY-MM-DD", true); + if (date.isValid()) { + return time.date_to_str(date.toDate()); + } + else { + return false; + } + }, +}); +}); |
