| OLD | NEW |
| (Empty) |
| 1 <!-- Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 Use of this source code is governed by a BSD-style license that can be | |
| 3 found in the LICENSE file. --> | |
| 4 | |
| 5 <link rel="import" href="cr-butterbar.html"> | |
| 6 <link rel="import" href="cr-button.html"> | |
| 7 <link rel="import" href="cr-dialog.html"> | |
| 8 <link rel="import" href="cr-toolbar.html"> | |
| 9 | |
| 10 <polymer-element name="cr-patchset-title-dialog" attributes="patchset"> | |
| 11 <template> | |
| 12 <link rel="stylesheet" href="common.css"> | |
| 13 <link rel="stylesheet" href="forms.css"> | |
| 14 | |
| 15 <dialog is="cr-dialog" id="dialog" on-cancel="{{ cancel }}"> | |
| 16 <cr-butterbar message="{{ butterbarMessage }}"></cr-butterbar> | |
| 17 | |
| 18 <h1>Edit patchset {{ patchset.sequence }}</h1> | |
| 19 | |
| 20 <fieldset class="form-fields" disabled?="{{ disabled }}"> | |
| 21 <div class="form-row"> | |
| 22 <label class="form-label" for="title">Title</label> | |
| 23 <div class="form-field"> | |
| 24 <input type="text" id="title" value="{{ title }}" autoco
mplete="off"> | |
| 25 </div> | |
| 26 </div> | |
| 27 </fieldset> | |
| 28 | |
| 29 <cr-toolbar> | |
| 30 <cr-button primary on-tap="{{ save }}">Save</cr-button> | |
| 31 <cr-button on-tap="{{ cancel }}">Cancel</cr-button> | |
| 32 </cr-toolbar> | |
| 33 </dialog> | |
| 34 </template> | |
| 35 <script> | |
| 36 Polymer("cr-patchset-title-dialog", { | |
| 37 created: function() { | |
| 38 this.patchset = null; | |
| 39 this.commit = true; | |
| 40 this.butterbarMessage = ""; | |
| 41 this.sending = false; | |
| 42 this.title = ""; | |
| 43 }, | |
| 44 cancel: function(event) { | |
| 45 this.close(); | |
| 46 }, | |
| 47 reset: function() { | |
| 48 this.sending = false; | |
| 49 this.butterbarMessage = ""; | |
| 50 this.commit = true; | |
| 51 this.title = this.patchset ? this.patchset.title : ""; | |
| 52 }, | |
| 53 close: function() { | |
| 54 this.reset(); | |
| 55 this.$.dialog.close(); | |
| 56 }, | |
| 57 save: function() { | |
| 58 this.sending = true; | |
| 59 this.butterbarMessage = "Saving..."; | |
| 60 this.patchset.setTitle(this.title) | |
| 61 .then(this.saveSuccess.bind(this)) | |
| 62 .catch(this.saveFailure.bind(this)); | |
| 63 }, | |
| 64 saveSuccess: function() { | |
| 65 this.close(); | |
| 66 }, | |
| 67 saveFailure: function(error) { | |
| 68 // TODO(esprehn): We should show an better error message. | |
| 69 this.sending = false; | |
| 70 this.butterbarMessage = "Error: " + error.message; | |
| 71 }, | |
| 72 showModal: function() { | |
| 73 if (!this.patchset) | |
| 74 return; | |
| 75 this.reset(); | |
| 76 this.$.dialog.showModal(); | |
| 77 }, | |
| 78 }); | |
| 79 </script> | |
| 80 </polymer-element> | |
| OLD | NEW |