Skip to content

Commit

Permalink
Merge 4eac805 into 473a1f8
Browse files Browse the repository at this point in the history
  • Loading branch information
itowtips committed Nov 25, 2022
2 parents 473a1f8 + 4eac805 commit a4ce213
Show file tree
Hide file tree
Showing 424 changed files with 22,430 additions and 260 deletions.
75 changes: 75 additions & 0 deletions app/assets/javascripts/gws/affair/menu.js
@@ -0,0 +1,75 @@
Gws_Affair_Menu = function (current, sessionKey) {
this.current = current;
this.sessionKey = sessionKey;
this.render();
};

Gws_Affair_Menu.prototype.render = function() {
var self = this;
this.initNarrow();
$(".toggle-narrow-page").on("click", function(){
var $a = $(this);
var $h3 = $a.closest("h3");
var $narrow = $h3.next(".narrow-page");

if ($narrow.hasClass("show")) {
self.hideNarrow($narrow, "fast");
$a.removeClass("down");
self.updateSession();
} else {
self.showNarrow($narrow, "fast");
$a.addClass("down");
self.updateSession();
}
return false;
});
};

Gws_Affair_Menu.prototype.showNarrow = function(ele, duration) {
$(ele).removeClass("hide");
$(ele).addClass("show");
$(ele).show(duration);
};

Gws_Affair_Menu.prototype.hideNarrow = function(ele, duration) {
$(ele).removeClass("show");
$(ele).hide(duration, function(){
$(this).addClass("hide");
});
};

Gws_Affair_Menu.prototype.getSession = function() {
var navi = sessionStorage.getItem(this.sessionKey);
if (navi) {
navi = navi.split(",")
} else {
navi = [];
}
return navi;
};

Gws_Affair_Menu.prototype.updateSession = function() {
var navi = $(".narrow-page[data-navi].show").map(function() { return $(this).attr("data-navi") }).toArray();
sessionStorage.setItem(this.sessionKey, navi.join(","));
};

Gws_Affair_Menu.prototype.initNarrow = function () {
var self = this;
$(".toggle-narrow-page").each(function(){
var $a = $(this);
var $h3 = $a.closest("h3");
var $narrow = $h3.next(".narrow-page");

var navi = self.getSession();
var content = $narrow.attr("data-navi");

if (navi.includes(content) || content == "<%= current_navi %>") {
self.showNarrow($narrow);
$a.addClass("down");
} else {
self.hideNarrow($narrow);
$a.removeClass("down");
}
});
self.updateSession();
};
62 changes: 62 additions & 0 deletions app/assets/javascripts/gws/affair/shift_records.js
@@ -0,0 +1,62 @@
Gws_Affair_ShiftRecords = function (el, options) {
this.el = el;
this.$el = $(el);
this.$toolbar = this.$el.find('.cell-toolbar');
this.options = options;
this.render();
};

Gws_Affair_ShiftRecords.prototype.render = function() {
var _this = this;

$(document).on('click', this.el + ' .shift-record', function(ev) {
ev.preventDefault();
ev.stopPropagation();
_this.onClickCell($(this));
});

$(this.el).find(".wrap-table").scroll(function () {
_this.$toolbar.hide();
});

_this.$toolbar.hide();
};

Gws_Affair_ShiftRecords.prototype.setFocus = function($cell) {
this.$el.find('.shift-record').removeClass('focus');
$cell.addClass('focus');
};

Gws_Affair_ShiftRecords.prototype.onClickCell = function($cell) {
this.setFocus($cell);

var day = $cell.data('day');
var user = $cell.data('user');

var showsToolbar = false;
var editable = this.options.editable;
if (editable) {
var url = this.options.shiftRecordUrl;
url = url.replace(':day', day);
url = url.replace(':user', user);

showsToolbar = true;
this.$toolbar.find('.edit').attr('href', url).show();
}

if (! showsToolbar) {
this.$toolbar.hide();
return;
}

var offset = $cell.offset();
if ($cell.hasClass('top')) {
offset.top -= this.$toolbar.outerHeight();
} else {
offset.top += $cell.outerHeight();
}

// call `show` and then call `offset`. order is important
this.$toolbar.show();
this.$toolbar.offset(offset);
};
29 changes: 27 additions & 2 deletions app/assets/javascripts/gws/attendance/attendance.js
Expand Up @@ -37,6 +37,14 @@ Gws_Attendance.prototype.render = function() {
$(this).find('.reason').show();
});

this.$el.find('.leave-file-tooltip').on('click', function(ev) {
ev.preventDefault();
ev.stopPropagation();

var href = $(this).attr("data-href");
$.colorbox({ href: href });
});

this.$el.find('select[name=year_month]').on('change', function() {
var val = $(this).val();
if (! val) {
Expand All @@ -46,7 +54,7 @@ Gws_Attendance.prototype.render = function() {
});

this.$toolbar.find(".punch").on("click", function() {
_this.onPunchClicked($(this).attr("href"), $(this).data("confirmation"));
_this.onPunchClicked($(this).attr("href"), $(this).data("confirmation"), $(this).data("type"));
return false;
});

Expand All @@ -64,6 +72,13 @@ Gws_Attendance.prototype.render = function() {
_this.onClickMemo($(this));
});

$(document).on('click', this.el + ' .time-card .working-time-edit', function(ev) {
ev.preventDefault();
ev.stopPropagation();

_this.onClickWorkingTime($(this));
});

$(document).on('click', function() {
_this.hideToolbar();
_this.hideTooltip();
Expand All @@ -72,7 +87,7 @@ Gws_Attendance.prototype.render = function() {

Gws_Attendance.prototype.onPunchClicked = function(action, message) {
if (! action) {
return
return;
}

if (message) {
Expand Down Expand Up @@ -119,10 +134,14 @@ Gws_Attendance.prototype.onClickTime = function($cell) {
Gws_Attendance.prototype.onClickMemo = function($cell) {
this.onClickCell($cell, this.options.memoUrl);
};
Gws_Attendance.prototype.onClickWorkingTime = function($cell) {
this.onClickCell($cell, this.options.workingTimeUrl);
};

Gws_Attendance.prototype.setFocus = function($cell) {
this.$el.find('.time-card .time').removeClass('focus');
this.$el.find('.time-card .memo').removeClass('focus');
this.$el.find('.time-card .working_time').removeClass('focus');
$cell.addClass('focus');
};

Expand Down Expand Up @@ -157,6 +176,12 @@ Gws_Attendance.prototype.onClickCell = function($cell, urlTemplate) {
}
}

if (type === "working_time") {
if (this.isCellToday($cell)) {
editable = true;
}
}

var showsToolbar = false;
if (mode === "punch" && punchable && this.options.punchUrl) {
var url = this.options.punchUrl;
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/gws/attendance/portlet.js
Expand Up @@ -53,6 +53,7 @@ Gws_Attendance_Portlet.prototype.edit = function($button, fieldName) {
$a = $('<a/>', { href: url });
$a.colorbox({
open: true,
width: '90%',
onClosed: function() { $button.removeAttr('disabled'); }
});
};
8 changes: 6 additions & 2 deletions app/assets/javascripts/gws/lib/category.js
Expand Up @@ -9,7 +9,10 @@ Gws_Category_Navi.prototype.setBaseUrl = function(url) {
this.baseUrl = url;
};

Gws_Category_Navi.prototype.render = function(items) {
Gws_Category_Navi.prototype.render = function(items, opts) {
if (opts == null) {
opts = {};
}
if (items.length == 0) {
this.el.hide();
return;
Expand All @@ -20,6 +23,7 @@ Gws_Category_Navi.prototype.render = function(items) {
var last_depth = -1;
var path = location.href.replace(/https?:\/\/.*?\//, '/');
var isCate = null;
var hideClose = opts["hideClose"];

$.each(items, function(idx, item) {
var depth = (item.name.match(/\//g) || []).length;
Expand All @@ -45,7 +49,7 @@ Gws_Category_Navi.prototype.render = function(items) {
this.el.find('.dropdown-menu').append(html.join(''));

var toggle = this.el.find('.dropdown-toggle');
if (isCate) {
if (!hideClose && isCate) {
var icon = '<i class="material-icons md-18 md-dark">&#xE14C;</i>';
toggle.after('<a class="ml-1" href="' + toggle.attr('href') + '">' + icon + '</a>');
}
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/gws/script.js
Expand Up @@ -28,6 +28,8 @@
//= require gws/attendance/portlet
//= require gws/presence/user
//= require gws/share/folder_toolbar
//= require gws/affair/menu
//= require gws/affair/shift_records

SS.ready(function () {
// external link
Expand Down

0 comments on commit a4ce213

Please sign in to comment.