Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
32bf884a
Commit
32bf884a
authored
Jun 23, 2015
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy window/Edit.js from manager to manager5
parent
56678698
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
251 additions
and
0 deletions
+251
-0
Edit.js
www/manager5/window/Edit.js
+251
-0
No files found.
www/manager5/window/Edit.js
0 → 100644
View file @
32bf884a
// fixme: how can we avoid those lint errors?
/*jslint confusion: true */
Ext
.
define
(
'
PVE.window.Edit
'
,
{
extend
:
'
Ext.window.Window
'
,
alias
:
'
widget.pveWindowEdit
'
,
resizable
:
false
,
// use this tio atimatically generate a title like
// Create: <subject>
subject
:
undefined
,
// set create to true if you want a Create button (instead
// OK and RESET)
create
:
false
,
// set to true if you want an Add button (instead of Create)
isAdd
:
false
,
// set to true if you want an Remove button (instead of Create)
isRemove
:
false
,
backgroundDelay
:
0
,
showProgress
:
false
,
isValid
:
function
()
{
var
me
=
this
;
var
form
=
me
.
formPanel
.
getForm
();
return
form
.
isValid
();
},
getValues
:
function
(
dirtyOnly
)
{
var
me
=
this
;
var
values
=
{};
var
form
=
me
.
formPanel
.
getForm
();
form
.
getFields
().
each
(
function
(
field
)
{
if
(
!
field
.
up
(
'
inputpanel
'
)
&&
(
!
dirtyOnly
||
field
.
isDirty
()))
{
PVE
.
Utils
.
assemble_field_data
(
values
,
field
.
getSubmitData
());
}
});
Ext
.
Array
.
each
(
me
.
query
(
'
inputpanel
'
),
function
(
panel
)
{
PVE
.
Utils
.
assemble_field_data
(
values
,
panel
.
getValues
(
dirtyOnly
));
});
return
values
;
},
setValues
:
function
(
values
)
{
var
me
=
this
;
var
form
=
me
.
formPanel
.
getForm
();
Ext
.
iterate
(
values
,
function
(
fieldId
,
val
)
{
var
field
=
form
.
findField
(
fieldId
);
if
(
field
&&
!
field
.
up
(
'
inputpanel
'
))
{
field
.
setValue
(
val
);
if
(
form
.
trackResetOnLoad
)
{
field
.
resetOriginalValue
();
}
}
});
Ext
.
Array
.
each
(
me
.
query
(
'
inputpanel
'
),
function
(
panel
)
{
panel
.
setValues
(
values
);
});
},
submit
:
function
()
{
var
me
=
this
;
var
form
=
me
.
formPanel
.
getForm
();
var
values
=
me
.
getValues
();
Ext
.
Object
.
each
(
values
,
function
(
name
,
val
)
{
if
(
values
.
hasOwnProperty
(
name
))
{
if
(
Ext
.
isArray
(
val
)
&&
!
val
.
length
)
{
values
[
name
]
=
''
;
}
}
});
if
(
me
.
digest
)
{
values
.
digest
=
me
.
digest
;
}
if
(
me
.
backgroundDelay
)
{
values
.
background_delay
=
me
.
backgroundDelay
;
}
var
url
=
me
.
url
;
if
(
me
.
method
===
'
DELETE
'
)
{
url
=
url
+
"
?
"
+
Ext
.
Object
.
toQueryString
(
values
);
values
=
undefined
;
}
PVE
.
Utils
.
API2Request
({
url
:
url
,
waitMsgTarget
:
me
,
method
:
me
.
method
||
(
me
.
backgroundDelay
?
'
POST
'
:
'
PUT
'
),
params
:
values
,
failure
:
function
(
response
,
options
)
{
if
(
response
.
result
&&
response
.
result
.
errors
)
{
form
.
markInvalid
(
response
.
result
.
errors
);
}
Ext
.
Msg
.
alert
(
gettext
(
'
Error
'
),
response
.
htmlStatus
);
},
success
:
function
(
response
,
options
)
{
me
.
close
();
if
((
me
.
backgroundDelay
||
me
.
showProgress
)
&&
response
.
result
.
data
)
{
var
upid
=
response
.
result
.
data
;
var
win
=
Ext
.
create
(
'
PVE.window.TaskProgress
'
,
{
upid
:
upid
});
win
.
show
();
}
}
});
},
load
:
function
(
options
)
{
var
me
=
this
;
var
form
=
me
.
formPanel
.
getForm
();
options
=
options
||
{};
var
newopts
=
Ext
.
apply
({
waitMsgTarget
:
me
},
options
);
var
createWrapper
=
function
(
successFn
)
{
Ext
.
apply
(
newopts
,
{
url
:
me
.
url
,
method
:
'
GET
'
,
success
:
function
(
response
,
opts
)
{
form
.
clearInvalid
();
me
.
digest
=
response
.
result
.
data
.
digest
;
if
(
successFn
)
{
successFn
(
response
,
opts
);
}
else
{
me
.
setValues
(
response
.
result
.
data
);
}
// hack: fix ExtJS bug
Ext
.
Array
.
each
(
me
.
query
(
'
radiofield
'
),
function
(
f
)
{
f
.
resetOriginalValue
();
});
},
failure
:
function
(
response
,
opts
)
{
Ext
.
Msg
.
alert
(
gettext
(
'
Error
'
),
response
.
htmlStatus
,
function
()
{
me
.
close
();
});
}
});
};
createWrapper
(
options
.
success
);
PVE
.
Utils
.
API2Request
(
newopts
);
},
initComponent
:
function
()
{
var
me
=
this
;
if
(
!
me
.
url
)
{
throw
"
no url specified
"
;
}
var
items
=
Ext
.
isArray
(
me
.
items
)
?
me
.
items
:
[
me
.
items
];
me
.
items
=
undefined
;
me
.
formPanel
=
Ext
.
create
(
'
Ext.form.Panel
'
,
{
url
:
me
.
url
,
method
:
me
.
method
||
'
PUT
'
,
trackResetOnLoad
:
true
,
bodyPadding
:
10
,
border
:
false
,
defaults
:
{
border
:
false
},
fieldDefaults
:
Ext
.
apply
({},
me
.
fieldDefaults
,
{
labelWidth
:
100
,
anchor
:
'
100%
'
}),
items
:
items
});
var
form
=
me
.
formPanel
.
getForm
();
var
submitBtn
=
Ext
.
create
(
'
Ext.Button
'
,
{
text
:
me
.
create
?
(
me
.
isAdd
?
gettext
(
'
Add
'
)
:
(
me
.
isRemove
?
gettext
(
'
Remove
'
)
:
gettext
(
'
Create
'
)))
:
gettext
(
'
OK
'
),
disabled
:
!
me
.
create
,
handler
:
function
()
{
me
.
submit
();
}
});
var
resetBtn
=
Ext
.
create
(
'
Ext.Button
'
,
{
text
:
'
Reset
'
,
disabled
:
true
,
handler
:
function
(){
form
.
reset
();
}
});
var
set_button_status
=
function
()
{
var
valid
=
form
.
isValid
();
var
dirty
=
form
.
isDirty
();
submitBtn
.
setDisabled
(
!
valid
||
!
(
dirty
||
me
.
create
));
resetBtn
.
setDisabled
(
!
dirty
);
};
form
.
on
(
'
dirtychange
'
,
set_button_status
);
form
.
on
(
'
validitychange
'
,
set_button_status
);
var
colwidth
=
300
;
if
(
me
.
fieldDefaults
&&
me
.
fieldDefaults
.
labelWidth
)
{
colwidth
+=
me
.
fieldDefaults
.
labelWidth
-
100
;
}
var
twoColumn
=
items
[
0
].
column1
||
items
[
0
].
column2
;
if
(
me
.
subject
&&
!
me
.
title
)
{
me
.
title
=
PVE
.
Utils
.
dialog_title
(
me
.
subject
,
me
.
create
,
me
.
isAdd
);
}
Ext
.
applyIf
(
me
,
{
modal
:
true
,
layout
:
'
auto
'
,
width
:
twoColumn
?
colwidth
*
2
:
colwidth
,
border
:
false
,
items
:
[
me
.
formPanel
],
buttons
:
me
.
create
?
[
submitBtn
]
:
[
submitBtn
,
resetBtn
]
});
me
.
callParent
();
// always mark invalid fields
me
.
on
(
'
afterlayout
'
,
function
()
{
me
.
isValid
();
});
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment