forked from Jigsaw-Code/outline-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-rename-dialog.html
73 lines (69 loc) · 2.7 KB
/
server-rename-dialog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!--
Copyright 2018 The Outline Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<link rel="import" href="../bower_components/paper-dialog/paper-dialog.html">
<link rel='import' href='../bower_components/paper-input/paper-input.html'>
<dom-module id="server-rename-dialog">
<template>
<style>
h3 {
margin-bottom: 0;
}
paper-input {
margin-top: 0;
--paper-input-container-focus-color: var(--medium-green);
}
</style>
<paper-dialog id="renameDialog" with-backdrop>
<h3>[[localize('server-rename')]]</h3>
<paper-input id="serverNameInput" always-float-label maxlength="100" tabindex="0"></paper-input>
<div class="buttons">
<paper-button dialog-dismiss>[[localize('cancel')]]</paper-button>
<paper-button dialog-confirm on-tap="_saveRename">[[localize('save')]]</paper-button>
</div>
</paper-dialog>
</template>
<script>
'use strict';
Polymer({
is: 'server-rename-dialog',
properties: {
// Need to declare localize function passed in from parent, or else
// localize() calls within the template won't be updated.
localize: Function,
rootPath: String,
__serverName: String,
__serverId: String
},
open: function(serverName, serverId) {
// Store the initial serverName so we can know if it changed, and
// store the serverId so we can emit the rename request event.
this.__serverName = serverName;
this.__serverId = serverId;
this.$.serverNameInput.value = serverName;
this.$.renameDialog.open();
// Focus on serverNameInput, only after the dialog has been displayed.
Polymer.RenderStatus.afterNextRender(this, () => {
this.$.serverNameInput.focus();
});
},
_saveRename: function() {
const newName = this.$.serverNameInput.value;
if (newName !== this.__serverName) {
this.fire('RenameRequested', {serverId: this.__serverId, newName: newName});
}
}
});
</script>
</dom-module>