Files
web-doc-editor/js/ui/cmp/DirectActionWin.js
Peter Kokot f06fee3640 Sync final newlines
This patch adds some missing newlines and trims multiple final newlines
into a single newline.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-02 03:44:40 +02:00

205 lines
6.8 KiB
JavaScript

Ext.namespace('ui','ui.cmp');
ui.cmp.DirectActionWin = Ext.extend(Ext.Window,
{
title : _('Live action'),
layout : 'form',
iconCls : 'iconDirectAction',
width : 850,
height : 450,
resizable : false,
modal : true,
autoScroll : true,
closeAction: 'close',
padding: 10,
tools: [{
id:'restore',
hidden: true,
handler: function(e,tEl,p,tc) {
p.toggleMaximize();
p.tools['maximize'].show();
p.tools['restore'].hide();
}
},{
id:'maximize',
handler: function(e,tEl,p,tc) {
p.toggleMaximize();
p.tools['maximize'].hide();
p.tools['restore'].show();
}
}],
buttonAlign: 'center',
buttons : [{
text: _('Save'),
handler: function()
{
// Get value
var action, patchID, idDB, win = this.ownerCt.ownerCt;
action = win.items.items[1].items.items[0].getValue();
patchID = win.items.items[1].items.items[1].getValue();
idDB = win.idDB;
// We need a patch with this action
if( action == 'putIntoMyPatches' && patchID == '' ) {
win.items.items[1].items.items[1].markInvalid();
win.items.items[1].items.items[1].focus();
return;
}
XHR({
scope: this,
params: {
task: 'setDirectAction',
action: action,
patchID: patchID,
idDB: idDB
},
success: function(r) {
var o = Ext.util.JSON.decode(r.responseText);
// We reload some stores
ui.cmp.WorkTreeGrid.getInstance().getRootNode().reload();
ui.cmp.PatchesTreeGrid.getInstance().getRootNode().reload();
// We close this window
win.close();
}
});
}
},'->',{
text : _('Close'),
handler : function()
{
this.ownerCt.ownerCt.close();
}
}],
displayData: function(info)
{
this.items.items[0].setText(info.fileInfo.lang + info.fileInfo.path + info.fileInfo.name + ' ' + _('by') + ' <b>' + info.userInfo.vcs_login + '</b> ' + _('on') + ' ' + info.fileInfo.date, false);
this.items.items[2].update(info.vcsDiff);
// We select the right action
this.items.items[1].items.items[0].setValue(this.action);
// Do we need to display patchList and Add button ?
if( this.action == 'deleteThisChange' )
{
this.items.items[1].items.items[1].hide();
//this.items.items[1].items.items[2].hide();
Ext.getCmp('Action-win-btn-add-new-patch').hide();
}
if( this.action == 'putIntoMyPatches' )
{
this.items.items[1].items.items[1].show();
//this.items.items[1].items.items[2].show();
Ext.getCmp('Action-win-btn-add-new-patch').show();
}
},
initComponent : function()
{
Ext.apply(this,
{
items: [{
xtype:'label',
fieldLabel: _('Modified file'),
text: '-'
},{
xtype:'compositefield',
fieldLabel: _('Action'),
items: [{
xtype : 'combo',
allowBlank: false,
editable:false,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
id: 'putIntoMyPatches',
fields: [
'actionID',
'actionText'
],
data: [['putIntoMyPatches', _('Put into this patch:')], ['deleteThisChange', _('Delete this change')]]
}),
valueField: 'actionID',
displayField: 'actionText',
listeners: {
select: function(combo, record, index)
{
if( record.data.actionID == 'deleteThisChange' )
{
combo.ownerCt.items.items[1].hide();
combo.ownerCt.items.items[2].hide();
}
if( record.data.actionID == 'putIntoMyPatches' )
{
combo.ownerCt.items.items[1].show();
combo.ownerCt.items.items[2].show();
}
}
}
},{
xtype : 'combo',
allowBlank: false,
editable:false,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
store: PhDOE.user.patchList,
valueField: 'id',
displayField: 'name'
},{
xtype: 'button',
iconCls: 'iconAdd',
id: 'Action-win-btn-add-new-patch',
tooltip: _('Create a new patch'),
handler: function() {
var win = new ui.cmp.ManagePatchPrompt({
title: _('Create a new patch')
});
win.show(this.el);
}
}]
},{
xtype:'label',
fieldLabel: _('Diff'),
cls: 'diff-content'
}],
listeners: {
afterrender: function()
{
XHR({
scope: this,
params: {
task: 'getDirectActionData',
action: this.action,
idDB: this.idDB
},
success: function(r) {
var o = Ext.util.JSON.decode(r.responseText);
if( !o.fileInfo ) {
this.close();
PhDOE.notify('error', _('Live action'), _('This live action didn\'t exist'));
return;
}
this.displayData(o);
}
});
}
}
});
ui.cmp.DirectActionWin.superclass.initComponent.call(this);
this.show();
}
});