From f2823183476f586ad65497f67b8229c6cbc7d675 Mon Sep 17 00:00:00 2001 From: Volkan Gezer Date: Wed, 9 Apr 2014 23:22:59 +0200 Subject: [PATCH 1/2] Let users set a default calendar for new events This should fix: #348 Users can set one calendar default by clicking on the star. New events will be created in the default calendar. --- ajax/calendar/delete.php | 3 +-- ajax/calendar/makedefault.php | 25 ++++++++++++++++++++ css/style.css | 10 ++++++++ img/star.png | Bin 0 -> 521 bytes js/calendar.js | 14 +++++++++++ js/on-event.js | 3 +++ lib/calendar.php | 22 +++++++++++++++++ templates/part.choosecalendar.rowfields.php | 7 ++++++ templates/part.eventform.php | 2 +- 9 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 ajax/calendar/makedefault.php create mode 100644 img/star.png diff --git a/ajax/calendar/delete.php b/ajax/calendar/delete.php index f3924bbfe..834b026ad 100644 --- a/ajax/calendar/delete.php +++ b/ajax/calendar/delete.php @@ -11,7 +11,7 @@ OCP\JSON::checkAppEnabled('calendar'); OCP\JSON::callCheck(); -$cal = $_POST["calendarid"]; +$cal = isset($_POST["calendarid"]) ? $_POST["calendarid"] : null; try { $del = OC_Calendar_Calendar::deleteCalendar($cal); @@ -22,5 +22,4 @@ } } catch(Exception $e) { OCP\JSON::error(array('message'=>$e->getMessage())); - exit; } diff --git a/ajax/calendar/makedefault.php b/ajax/calendar/makedefault.php new file mode 100644 index 000000000..42a7f29c4 --- /dev/null +++ b/ajax/calendar/makedefault.php @@ -0,0 +1,25 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::callCheck(); + +$cal = isset($_POST["calendarid"]) ? $_POST["calendarid"] : null; + +try { + $def = OC_Calendar_Calendar::makeDefault($cal); + if($def === true) { + OCP\JSON::success(); + }else{ + OCP\JSON::error(array('error'=>'dberror')); + } +} catch(Exception $e) { + OCP\JSON::error(array('message'=>$e->getMessage())); +} diff --git a/css/style.css b/css/style.css index 9244f4552..b62a7c726 100644 --- a/css/style.css +++ b/css/style.css @@ -551,6 +551,16 @@ button.category{margin:0 3px;} top: 44px; } +.icon-default { + background-image: url('../img/star.png'); +} + +.not-set { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)"; + filter: alpha(opacity = 10); + opacity: 0.1; +} + #navigation-list #caldav_url_entry { min-height: 0; } diff --git a/img/star.png b/img/star.png new file mode 100644 index 0000000000000000000000000000000000000000..2fe31d9443eb82281a1840c0de2ce99c133a2214 GIT binary patch literal 521 zcmV+k0`~ohP)%e*#hSz}bzX`hC?y{uol8)8yYM$pyvuc&+d2D+PSdz3190$$-+mem~ z*xtAO1b8p$YgJW+?LFHc8bBuL9&lEYW~xY$q?=>gL15q=uoFg6^frp3T}c;#6LWU* z4{YyBx>FRz^RZ%@rl%T>#v`D2XnjWG58y>rRk!>7{%4rj>~J{z7RT``NgK9Tr^m5v zNiVCay4COZKaR(l64|r;eS!6#w#&)bG(jxs^r5=#1KYm<^cQPE5X5r{B(2(R*Uevm zhrk2dpXyi}XwM`_lB8Kx)rGq78L(Lt#r?7@cYsaXPirHcJkQ5BGt( + 'You do not have the permissions to update this calendar.' + ) + ); + } + } + OCP\Config::setUserValue(OCP\User::getUser(), "calendar", "defaultcalendar", $id); + + return true; + } + /** * @brief merges two calendars * @param integer $id1 diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index 37b93c883..b5d596e23 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -40,6 +40,13 @@ + + + > + + + + diff --git a/templates/part.eventform.php b/templates/part.eventform.php index 82d7fc1b4..798e38b60 100644 --- a/templates/part.eventform.php +++ b/templates/part.eventform.php @@ -30,7 +30,7 @@ } } $sortedCalendars = array_merge($enabledCalendars, $disabledCalendars); - print_unescaped(OCP\html_select_options($sortedCalendars, $_['calendar'], array('value'=>'id', 'label'=>'displayname'))); ?> + print_unescaped(OCP\html_select_options($sortedCalendars, OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'defaultcalendar', $_['calendar']), array('value'=>'id', 'label'=>'displayname'))); ?> From b0eaaa83e485b9cd8fe7bff0127e95e0c6cee760 Mon Sep 17 00:00:00 2001 From: Volkan Gezer Date: Sat, 6 Dec 2014 15:28:34 +0100 Subject: [PATCH 2/2] css tweaks for buttons --- css/style.css | 271 ++++++++++++++++++++ templates/calendar.php | 2 +- templates/part.choosecalendar.rowfields.php | 39 +-- 3 files changed, 294 insertions(+), 18 deletions(-) diff --git a/css/style.css b/css/style.css index b62a7c726..ee6e9d2cc 100644 --- a/css/style.css +++ b/css/style.css @@ -593,3 +593,274 @@ button.ui-multiselect{ height:26px; text-align:left; } + +/* New boilerplate menu */ + +/** + * Backports for ownCloud 7 + */ +#app-navigation .active.with-menu > a, +#app-navigation .with-counter > a { + padding-right: 50px; +} + +#app-navigation .active.with-menu.with-counter > a { + padding-right: 90px; +} + +#app-navigation > .with-icon ul li > a, +#app-navigation > .with-icon ul li.app-navigation-entry-loading > a { + padding-left: 68px; + background-position: 44px center; +} + +#app-navigation li:hover > a, +#app-navigation .selected, +#app-navigation .selected a { + background-color: #ddd; +} + +#app-navigation .with-icon a, +#app-navigation .app-navigation-entry-loading a { + padding-left: 44px; + background-size: 16px 16px; + background-position: 14px center; + background-repeat: no-repeat; +} + +#app-navigation .collapsible.open { + background-image: linear-gradient(top, rgb(238,238,238) 0%, rgb(245,245,245) 100%); + background-image: -o-linear-gradient(top, rgb(238,238,238) 0%, rgb(245,245,245) 100%); + background-image: -moz-linear-gradient(top, rgb(238,238,238) 0%, rgb(245,245,245) 100%); + background-image: -webkit-linear-gradient(top, rgb(238,238,238) 0%, rgb(245,245,245) 100%); + background-image: -ms-linear-gradient(top, rgb(238,238,238) 0%, rgb(245,245,245) 100%); +} + +#app-navigation > ul .collapsible.open:hover { + box-shadow: inset 0 0 3px #ddd; +} + +#app-navigation > ul .collapsible.open ul { + display: block; +} + +/* Deleted entries with undo button */ +#app-navigation .app-navigation-entry-deleted { + display: inline-block; + height: 44px; + width: 100%; +} + + #app-navigation .app-navigation-entry-deleted-description { + padding-left: 12px; + position: relative; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + display: inline-block; + width: 201px; /* fallback for IE8 */ + width: calc(100% - 49px); + line-height: 44px; + float: left; + } + + #app-navigation .app-navigation-entry-deleted-button { + margin: 0; + height: 44px; + width: 44px; + line-height: 44px; + border: 0; + display: inline-block; + background-color: transparent; + opacity: .5; + } + + #app-navigation .app-navigation-entry-deleted-button:hover { + opacity: 1; + } + + +/** + * App navigation utils, buttons and counters for drop down menu + */ +#app-navigation .app-navigation-entry-utils { + position: absolute; + top: 0; + right: 0; + z-index: 10; +} + + #app-navigation .app-navigation-entry-utils ul { + display: block !important; + } + + + #app-navigation .app-navigation-entry-utils li { + float: left; + width: 44px !important; + height: 44px; + line-height: 44px; + } + + #app-navigation .active > .app-navigation-entry-utils li { + display: inline-block; + } + + #app-navigation .app-navigation-entry-utils button { + height: 38px; + width: 38px; + line-height: 38px; + float: left; + } + + #app-navigation .app-navigation-entry-utils-menu-button { + display: none; + } + #app-navigation .app-navigation-entry-utils-menu-button button { + border: 0; + opacity: .5; + background-color: transparent; + background-repeat: no-repeat; + background-position: center; + background-image: url('../img/more.svg'); + } + + #app-navigation .app-navigation-entry-utils-menu-button:hover button, + #app-navigation .app-navigation-entry-utils-menu-button:focus button { + background-color: transparent; + opacity: 1; + } + + #app-navigation .app-navigation-entry-utils-counter { + overflow: hidden; + text-overflow: hidden; + text-align: right; + font-size: 9pt; + width: 38px; + line-height: 44px; + padding: 0 10px; + } + + #app-navigation .app-navigation-entry-utils ul, + #app-navigation .app-navigation-entry-menu ul { + list-style-type: none; + } + +#app-navigation .app-navigation-entry-menu { + display: none; + position: absolute; + background-color: #eee; + color: #333; + border-radius: 3px; + border-top-right-radius: 0px; + z-index: 110; + margin: -5px 14px 5px 10px; + right: 0; + border: 1px solid #bbb; + -webkit-filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + -moz-filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + -ms-filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + -o-filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); + filter: drop-shadow(0 0 5px rgba(150, 150, 150, 0.75)); +} + +#app-navigation .app-navigation-entry-menu.open { + display: block; +} + +/* miraculous border arrow stuff */ +#app-navigation .app-navigation-entry-menu:after, +#app-navigation .app-navigation-entry-menu:before { + bottom: 100%; + right: 0; /* change this to adjust the arrow position */ + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; +} + +#app-navigation .app-navigation-entry-menu:after { + border-color: rgba(238, 238, 238, 0); + border-bottom-color: #eee; + border-width: 10px; + margin-left: -10px; +} +#app-navigation .app-navigation-entry-menu:before { + border-color: rgba(187, 187, 187, 0); + border-bottom-color: #bbb; + border-width: 11px; + margin-left: -11px; +} + + /* list of options for an entry */ + #app-navigation .app-navigation-entry-menu ul { + display: block !important; + } + + #app-navigation .app-navigation-entry-menu li { + float: left; + width: 38px !important; + } + + #app-navigation .app-navigation-entry-menu li button { + float: right; + width: 36px !important; + height: 36px; + line-height: 36px; + border: 0; + opacity: .5; + background-color: transparent; + } + + #app-navigation .app-navigation-entry-menu li button:hover, + #app-navigation .app-navigation-entry-menu li button:focus { + opacity: 1; + background-color: transparent; + } + +/* editing an entry */ +#app-navigation .app-navigation-entry-edit { + padding-left: 5px; + padding-right: 5px; + display: inline-block; + height: 39px; + width: 100%; +} + + #app-navigation .app-navigation-entry-edit input { + border-bottom-right-radius: 0; + border-top-right-radius: 0; + width: 204px; /* fallback for IE8 */ + width: calc(100% - 36px); + padding: 5px; + margin-right: 0; + height: 38px; + float: left; + border: 1px solid rgba(190,190,190,.9); + } + + #app-navigation .app-navigation-entry-edit button, + #app-navigation .app-navigation-entry-edit input[type="submit"] { + width: 36px; + height: 38px; + float: left; + } + + #app-navigation .app-navigation-entry-edit .icon-checkmark { + border-bottom-left-radius: 0; + border-top-left-radius: 0; + border-left: 0; + margin-right: 0; + } + +#app-content { + z-index: 25; +} + +#app-settings, +#expanddiv { + z-index: 15; +} + diff --git a/templates/calendar.php b/templates/calendar.php index b391a9b20..98730b5f8 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -24,7 +24,7 @@ "); + print_unescaped("
  • "); $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $option_calendars[$i]); if ($option_calendars[$i]['userid'] != OCP\User::getUser()) { diff --git a/templates/part.choosecalendar.rowfields.php b/templates/part.choosecalendar.rowfields.php index b5d596e23..694e4a969 100644 --- a/templates/part.choosecalendar.rowfields.php +++ b/templates/part.choosecalendar.rowfields.php @@ -1,5 +1,4 @@ - - - +
    +
      +
    • - - +
    • - - +
    • +
    • +
    +
    +
    +
      +
    • - +
    • - +
    • - +
    • - +
    • - +
    • - +
    • > - +
    • - +
    • - - +
    • +
    +
    \ No newline at end of file