File tree Expand file tree Collapse file tree 3 files changed +50
-5
lines changed
resources/templates/dialogs Expand file tree Collapse file tree 3 files changed +50
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ define([
3434 throw "Invalid files handler format" ;
3535 }
3636
37+ handler . id = handlerId ;
38+
3739 if ( handler . View ) {
3840 handler . open = function ( file ) {
3941 var path = file . path ( ) ;
@@ -85,15 +87,24 @@ define([
8587 } ) ;
8688 }
8789
88- var handlers = getHandlers ( file ) ;
89- if ( _ . size ( handlers ) == 0 ) {
90+ var possibleHandlers = getHandlers ( file ) ;
91+ if ( _ . size ( possibleHandlers ) == 0 ) {
9092 dialogs . alert ( "Can't open this file" , "Sorry, No handler has been found to open this file. Try to find and install an addon to manage this file." ) ;
9193 return Q . reject ( new Error ( "No handler for this file" ) ) ;
9294 }
9395
94- // todo: dialog to choose the handler
95- var handler = _ . first ( handlers ) ;
96- return Q ( handler . open ( file ) ) ;
96+ if ( _ . size ( possibleHandlers ) == 1 ) {
97+ return Q ( _ . first ( possibleHandlers ) . open ( file ) ) ;
98+ }
99+
100+ var choices = { } ;
101+ _ . each ( possibleHandlers , function ( handler ) {
102+ choices [ handler . id ] = handler . name ;
103+ } )
104+ return dialogs . select ( "Open with..." , "Select the handler to open this file" , choices ) . then ( function ( value ) {
105+ var handler = handlers [ value ] ;
106+ return Q ( handler . open ( file ) ) ;
107+ } ) ;
97108 } ;
98109
99110 return {
Original file line number Diff line number Diff line change 1+ < div class ="modal-dialog ">
2+ < div class ="modal-content ">
3+ < div class ="modal-header ">
4+ < h4 class ="modal-title "> < %- options.title || "Select" %> </ h4 >
5+ </ div >
6+ < div class ="modal-body ">
7+ < p > < %= options.message %> </ p >
8+ < select class ="input form-control ">
9+ < % _.each(options.choices, function(choice, key) { %>
10+ < option value ="<%- key %> " < % if (options.default == key) { %> selected< % } %> > < %- choice %> </ option >
11+ < % }); %>
12+ </ select >
13+ </ div >
14+ < div class ="modal-footer ">
15+ < button class ="btn btn-default action-close "> Close</ button >
16+ < button class ="btn btn-success action-confirm "> OK</ button >
17+ </ div >
18+ </ div >
19+ </ div >
Original file line number Diff line number Diff line change @@ -42,6 +42,21 @@ define([
4242 } ) ;
4343 } ,
4444
45+ /*
46+ * Open a select dialog window
47+ */
48+ select : function ( title , message , choices , defaultChoice ) {
49+ return Dialogs . open ( null , {
50+ "title" : title ,
51+ "message" : message ,
52+ "dialog" : "select" ,
53+ "default" : defaultChoice ,
54+ "choices" : choices ,
55+ "autoFocus" : true ,
56+ "valueSelector" : "selectorPrompt"
57+ } ) ;
58+ } ,
59+
4560 /*
4661 * Open a confirmation dialog windows
4762 * @message : message to print
You can’t perform that action at this time.
0 commit comments