some more work on calendar import - new import is (nearly) done
This commit is contained in:
parent
5880bbee8f
commit
a4c2893128
5 changed files with 44 additions and 7 deletions
|
@ -37,7 +37,7 @@ if($_POST['method'] == 'new'){
|
|||
$newcal = true;
|
||||
}
|
||||
if($newcal){
|
||||
$id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']),'VEVENT,VTODO,VJOURNAL',null,0,$import->createCalendarColor());
|
||||
$id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']),'VEVENT,VTODO,VJOURNAL',null,0,strip_tags($_POST['calcolor']));
|
||||
OC_Calendar_Calendar::setCalendarActive($id, 1);
|
||||
}
|
||||
}else{
|
||||
|
|
|
@ -24,6 +24,8 @@ OCP\Util::connectHook('OC_Calendar', 'deleteCalendar', 'OC_Calendar_Share', 'pos
|
|||
OCP\Util::addscript('calendar','loader');
|
||||
OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min");
|
||||
OCP\Util::addStyle("3rdparty", "chosen/chosen");
|
||||
OCP\Util::addStyle('3rdparty/miniColors', 'jquery.miniColors');
|
||||
OCP\Util::addscript('3rdparty/miniColors', 'jquery.miniColors.min');
|
||||
OCP\App::addNavigationEntry( array(
|
||||
'id' => 'calendar_index',
|
||||
'order' => 10,
|
||||
|
|
7
apps/calendar/css/import.css
vendored
7
apps/calendar/css/import.css
vendored
|
@ -7,5 +7,8 @@
|
|||
#calendar_import_newcalform, #calendar_import_mergewarning, #calendar_import_process, #calendar_import_done{display:none;}
|
||||
#calendar_import_process_message, #calendar_import_status, #calendar_import_form_message, #calendar_import_mergewarning{text-align:center;}
|
||||
#calendar_import_form_message{font-weight: bold;}
|
||||
#calendar_import_newcalendar{width:96%;}
|
||||
.calendar_import_warning{border-color: #fc3333;}
|
||||
#calendar_import_newcalendar{width:415px;float:right;}
|
||||
#calendar_import_mergewarning{clear: both;}
|
||||
#calendar_import_defaultcolors{clear:both;margin: 0 auto;text-align: center;}
|
||||
.calendar_import_warning{border-color: #fc3333;}
|
||||
.calendar-colorpicker-color{display:inline-block;width:20px;height:5px;margin: 0 auto;cursor:pointer;border:2px solid transparent;}
|
|
@ -11,6 +11,7 @@ Calendar_Import={
|
|||
id: 0,
|
||||
method: '',
|
||||
calname: '',
|
||||
calcolor: '',
|
||||
progresskey: '',
|
||||
percentage: 0
|
||||
},
|
||||
|
@ -33,6 +34,7 @@ Calendar_Import={
|
|||
//init dialog
|
||||
$('#calendar_import_dialog').dialog({
|
||||
width : 500,
|
||||
resizable: false,
|
||||
close : function() {
|
||||
Calendar_Import.Dialog.close();
|
||||
}
|
||||
|
@ -44,6 +46,10 @@ Calendar_Import={
|
|||
$('#calendar_import_submit').click(function(){
|
||||
Calendar_Import.Core.process();
|
||||
});
|
||||
$('#calendar_import_mergewarning').click(function(){
|
||||
$('#calendar_import_newcalendar').attr('value', $('#calendar_import_availablename').val());
|
||||
Calendar_Import.Dialog.mergewarning($('#calendar_import_newcalendar').val());
|
||||
});
|
||||
$('#calendar_import_calendar').change(function(){
|
||||
if($('#calendar_import_calendar option:selected').val() == 'newcal'){
|
||||
$('#calendar_import_newcalform').slideDown('slow');
|
||||
|
@ -54,7 +60,16 @@ Calendar_Import={
|
|||
}
|
||||
});
|
||||
$('#calendar_import_newcalendar').keyup(function(){
|
||||
Calendar_Import.Dialog.mergewarning($('#calendar_import_newcalendar').val());
|
||||
Calendar_Import.Dialog.mergewarning($.trim($('#calendar_import_newcalendar').val()));
|
||||
});
|
||||
$('#calendar_import_newcalendar_color').miniColors({
|
||||
letterCase: 'uppercase'
|
||||
});
|
||||
$('.calendar-colorpicker-color').click(function(){
|
||||
var str = $(this).attr('rel');
|
||||
str = str.substr(1);
|
||||
$('#calendar_import_newcalendar_color').attr('value', str);
|
||||
$(".color-picker").miniColors('value', '#' + str);
|
||||
});
|
||||
//init progressbar
|
||||
$('#calendar_import_progressbar').progressbar({value: Calendar_Import.Store.percentage});
|
||||
|
@ -114,7 +129,7 @@ Calendar_Import={
|
|||
},
|
||||
send: function(){
|
||||
$.post(OC.filePath('calendar', 'ajax/import', 'import.php'),
|
||||
{progresskey: Calendar_Import.Store.progresskey, method: String (Calendar_Import.Store.method), calname: String (Calendar_Import.Store.calname), path: String (Calendar_Import.Store.path), file: String (Calendar_Import.Store.file), id: String (Calendar_Import.Store.id)}, function(data){
|
||||
{progresskey: Calendar_Import.Store.progresskey, method: String (Calendar_Import.Store.method), calname: String (Calendar_Import.Store.calname), path: String (Calendar_Import.Store.path), file: String (Calendar_Import.Store.file), id: String (Calendar_Import.Store.id), calcolor: String (Calendar_Import.Store.calcolor)}, function(data){
|
||||
if(data.status == 'success'){
|
||||
$('#calendar_import_progressbar').progressbar('option', 'value', 100);
|
||||
Calendar_Import.Store.percentage = 100;
|
||||
|
@ -136,6 +151,10 @@ Calendar_Import={
|
|||
Calendar_Import.Dialog.warning('#calendar_import_newcalendar');
|
||||
return false;
|
||||
}
|
||||
Calendar_Import.Store.calcolor = $.trim($('#calendar_import_newcalendar_color').val());
|
||||
if(Calendar_Import.Store.calcolor == ''){
|
||||
Calendar_Import.Store.calcolor = $('.calendar-colorpicker-color:first').attr('rel');
|
||||
}
|
||||
}else{
|
||||
Calendar_Import.Store.method = 'old';
|
||||
}
|
||||
|
|
|
@ -5,11 +5,14 @@ if(!$file){
|
|||
OCP\JSON::error(array('error'=>'404'));
|
||||
}
|
||||
$import = new OC_Calendar_Import($file);
|
||||
$import->setUserID(OCP\User::getUser());
|
||||
$newcalendarname = strip_tags($import->createCalendarName());
|
||||
$guessedcalendarname = $import->guessCalendarName();
|
||||
$guessedcalendarname = strip_tags($import->guessCalendarName());
|
||||
$calendarcolor = strip_tags($import->createCalendarColor());
|
||||
//loading calendars for select box
|
||||
$calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
$calendar_options[] = array('id'=>'newcal', 'displayname'=>$l->t('create a new calendar'));
|
||||
$defaultcolors = OC_Calendar_Calendar::getCalendarColorOptions();
|
||||
?>
|
||||
<div id="calendar_import_dialog" title="<?php echo $l->t("Import a calendar file");?>">
|
||||
<div id="calendar_import_form">
|
||||
|
@ -17,6 +20,7 @@ $calendar_options[] = array('id'=>'newcal', 'displayname'=>$l->t('create a new c
|
|||
<input type="hidden" id="calendar_import_filename" value="<?php echo $_['filename'];?>">
|
||||
<input type="hidden" id="calendar_import_path" value="<?php echo $_['path'];?>">
|
||||
<input type="hidden" id="calendar_import_progresskey" value="<?php echo rand() ?>">
|
||||
<input type="hidden" id="calendar_import_availablename" value="<?php echo $newcalendarname ?>">
|
||||
<div id="calendar_import_form_message"><?php echo $l->t('Please choose a calendar'); ?></div>
|
||||
<select style="width:100%;" id="calendar_import_calendar" name="calendar_import_calendar">
|
||||
<?php
|
||||
|
@ -26,8 +30,17 @@ $calendar_options[] = array('id'=>'newcal', 'displayname'=>$l->t('create a new c
|
|||
echo OCP\html_select_options($calendar_options, $calendar_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
||||
?>
|
||||
</select>
|
||||
<br><br>
|
||||
<div id="calendar_import_newcalform">
|
||||
<input id="calendar_import_newcalendar" class="" type="text" placeholder="<?php echo $l->t('Name of new calendar'); ?>" value="<?php echo $newcalendarname ?>"><br>
|
||||
<input id="calendar_import_newcalendar_color" class="color-picker" type="hidden" size="6" value="<?php echo substr($calendarcolor,1); ?>">
|
||||
<input id="calendar_import_newcalendar" class="" type="text" placeholder="<?php echo $l->t('Name of new calendar'); ?>" value="<?php echo $guessedcalendarname ?>"><br>
|
||||
<div id="calendar_import_defaultcolors">
|
||||
<?php
|
||||
foreach($defaultcolors as $color){
|
||||
echo '<span class="calendar-colorpicker-color" rel="' . $color . '" style="background-color: ' . $color . ';"></span>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<!--<input id="calendar_import_generatename" type="button" class="button" value="<?php echo $l->t('Take an available name!'); ?>"><br>-->
|
||||
<div id="calendar_import_mergewarning" class="hint"><?php echo $l->t('A Calendar with this name already exists. If you continue anyhow, these calendars will be merged.'); ?></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue