Completed
Pull Request — master (#19)
by Wachter
07:23
created

Resources/public/dist/components/comments/edit/main.js   A

Complexity

Total Complexity 24
Complexity/F 1.09

Size

Lines of Code 1
Function Count 22

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 24
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 0
nc 8
mnd 1
bc 22
fnc 22
bpm 1
cpm 1.0909
noi 1
1
define(["jquery","services/sulucomment/comment-manager","services/sulucomment/comment-router"],function(a,b,c){"use strict";return{defaults:{translations:{headline:"sulu_comment.comments",published:"sulu_comment.comment.published",unpublished:"sulu_comment.comment.unpublished"}},header:function(){var a={save:{},edit:{options:{dropdownItems:{"delete":{options:{callback:this["delete"].bind(this)}}}}},state:{parent:"toggler",options:{title:this.translations.unpublished}}};return 1==this.data.state&&(a.state={parent:"toggler-on",options:{title:this.translations.published,callback:this.toggleState.bind(this)}}),{title:function(){return this.translations.headline}.bind(this),tabs:{url:"/admin/content-navigations?alias=comments",options:{data:function(){return this.sandbox.util.extend(!1,{},this.data)}.bind(this)},componentOptions:{values:this.data}},toolbar:{buttons:a}}},loadComponentData:function(){var c=a.Deferred();return this.options.id?(b.load(this.options.id).done(function(a){c.resolve(a)}),c):(c.resolve({}),c)},initialize:function(){this.bindCustomEvents()},bindCustomEvents:function(){this.sandbox.on("sulu.header.back",this.toList.bind(this)),this.sandbox.on("sulu.tab.dirty",this.enableSave.bind(this)),this.sandbox.on("sulu.toolbar.save",this.save.bind(this)),this.sandbox.on("sulu.tab.data-changed",this.setData.bind(this)),this.sandbox.on("husky.toggler.sulu-toolbar.changed",this.toggleState.bind(this))},toList:function(){c.toList()},toggleState:function(){return this.sandbox.emit("sulu.header.toolbar.item.loading","save"),0==this.data.state?(this.sandbox.emit("sulu.header.toolbar.button.set","state",{title:this.translations.published}),b.publish(this.data.id).done(function(a){this.data.state=a.state,this.sandbox.emit("sulu.header.toolbar.item.enable","save",!1)}.bind(this))):(this.sandbox.emit("sulu.header.toolbar.button.set","state",{title:this.translations.unpublished}),b.unpublish(this.data.id).done(function(a){this.data.state=a.state,this.sandbox.emit("sulu.header.toolbar.item.enable","save",!1)}.bind(this)))},"delete":function(){this.sandbox.emit("sulu.header.toolbar.item.loading","edit"),b["delete"](this.data.id).done(function(){this.sandbox.emit("sulu.header.toolbar.item.enable","edit",!1),c.toList()}.bind(this))},save:function(a){this.loadingSave(),this.saveTab().then(function(b){this.afterSave(a,b)}.bind(this))},setData:function(a){this.data=a},saveTab:function(){var b=a.Deferred();return this.sandbox.once("sulu.tab.saved",function(a){this.setData(a),b.resolve(a)}.bind(this)),this.sandbox.emit("sulu.tab.save"),b},enableSave:function(){this.sandbox.emit("sulu.header.toolbar.item.enable","save",!1)},loadingSave:function(){this.sandbox.emit("sulu.header.toolbar.item.loading","save")},afterSave:function(a,b){this.sandbox.emit("sulu.header.toolbar.item.disable","save",!0),this.sandbox.emit("sulu.header.saved",b)}}});
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...