SEO keywords must be unique

bzr revid: ddm@openerp.com-20130827085121-2vkxscag56dze107
This commit is contained in:
ddm
2013-08-27 10:51:21 +02:00
parent 85e54aba60
commit 48a8aa14a3
2 changed files with 17 additions and 4 deletions
+16 -3
View File
@@ -248,6 +248,16 @@
this.$el.modal();
},
listKeywords: function () {
var result = [];
this.$el.find('.js_seo_keyword').each(function () {
result.push($(this).text());
})
return _.uniq(result);
},
existsKeyword: function (word) {
return _.contains(this.listKeywords(), word);
},
confirmKeyword: function (e) {
if (e.keyCode == 13) {
this.addKeyword();
@@ -256,11 +266,14 @@
},
addKeyword: function () {
var word = this.$el.find('input[name=seo_page_keywords]').val();
new website.seo.Keyword({
keyword: word
}).appendTo(this.$el.find('.js_seo_keywords_list'));
if (!this.existsKeyword(word)) {
new website.seo.Keyword({
keyword: word
}).appendTo(this.$el.find('.js_seo_keywords_list'));
}
},
update: function () {
console.log(this.listKeywords());
// TODO: Persist changes
},
close: function () {
+1 -1
View File
@@ -99,7 +99,7 @@
</t>
<t t-name="website.seo_keyword">
<li><a href="#" class="oe_remove" data-action="remove-keyword"><i class="icon-trash"/></a> <span class="label seo-keyword"><t t-raw="widget.keyword"/></span></li>
<li><a href="#" class="oe_remove" data-action="remove-keyword"><i class="icon-trash"/></a> <span class="label js_seo_keyword"><t t-raw="widget.keyword"/></span></li>
</t>
<t t-name="website.carousel">